当前位置: 首页>>代码示例>>C#>>正文


C# NetIncomingMessage.ReadByte方法代码示例

本文整理汇总了C#中Lidgren.Network.NetIncomingMessage.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage.ReadByte方法的具体用法?C# NetIncomingMessage.ReadByte怎么用?C# NetIncomingMessage.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lidgren.Network.NetIncomingMessage的用法示例。


在下文中一共展示了NetIncomingMessage.ReadByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Decode

 public override void Decode(NetIncomingMessage msg)
 {
     findSixes = msg.ReadBoolean();
     nPosition = new HashSet<int>();
     for (int i = msg.ReadByte(); i > 0; i--)
         nPosition.Add(msg.ReadByte());
 }
开发者ID:TAMUCC-cosc3325-team2,项目名称:TheTeamGame,代码行数:7,代码来源:NumeralSearch.cs

示例2: readData

        public void readData(NetIncomingMessage msg)
        {
            while (msg.PositionInBytes < msg.LengthBytes)
            {
                Console.WriteLine("Data in buffer : " + (msg.LengthBytes - msg.PositionInBytes));
                PacketTypes pa = (PacketTypes)msg.ReadByte();

                Console.WriteLine(pa);
                switch (pa)
                {
                    case PacketTypes.ClientInput:

                        InputObject input = new InputObject();
                        InputParser.readBytes(msg, ref input);

                        Player p = Players[msg.SenderConnection.RemoteUniqueIdentifier];
                        p.Input = input;

                        break;
                    default:
                        Console.WriteLine("overflow : " + msg.ReadByte());
                        break;
                }
            }
        }
开发者ID:Harlonlonmo,项目名称:Network-Game,代码行数:25,代码来源:ServerObject.cs

示例3: Decode

 public void Decode(NetIncomingMessage im)
 {
     this.Username = im.ReadString();
     this.ID = im.ReadByte();
     this.Me = im.ReadBoolean();
     this.Color = new Color(im.ReadByte(), im.ReadByte(), im.ReadByte());
 }
开发者ID:Express50,项目名称:Bricklayer,代码行数:7,代码来源:PlayerJoinMessage.cs

示例4: HandleMessage

        private static void HandleMessage(NetIncomingMessage inc, NetServer server)
        {
            switch (inc.MessageType)
            {
                case NetIncomingMessageType.ConnectionApproval: //If ConnectionApproval request
                    if (inc.ReadByte() == (byte) PacketTypes.Headers.Login)
                    {
                        string username = inc.ReadString();
                        Console.WriteLine("New Login Request from: {0}", username);
                        if (username.Length > 1 & Players.Values.All(c => c.Name != username) &
                            !_badwordList.Contains(username, StringComparer.OrdinalIgnoreCase))
                        {
                            inc.SenderConnection.Approve();
                            NetOutgoingMessage connectedMessage = server.CreateMessage();
                            Thread.Sleep(500);
                            Console.WriteLine("Sending a ack to {0}", username);
                            connectedMessage.Write((byte) PacketTypes.Headers.LoggedIn);
                            connectedMessage.Write(true);
                            server.SendMessage(connectedMessage, inc.SenderConnection, NetDeliveryMethod.ReliableOrdered);
                        }
                        else
                        {
                            inc.SenderConnection.Deny("Bad Username");
                        }
                    }

                    break;

                case NetIncomingMessageType.Data:
                    byte packetheader = inc.ReadByte();
                    HandleProtocol(inc, packetheader, server);
                    break;

                case NetIncomingMessageType.StatusChanged:
                    Console.WriteLine(inc.SenderConnection + " status changed. " + inc.SenderConnection.Status);
                    if (inc.SenderConnection.Status == NetConnectionStatus.Disconnected)
                    {
                        Console.WriteLine("Player: {0} has disconnected",
                            Players[inc.SenderConnection.RemoteUniqueIdentifier].Name);
                        Players.Remove(inc.SenderConnection.RemoteUniqueIdentifier);
                    }
                    break;

                case NetIncomingMessageType.DiscoveryRequest:
                    NetOutgoingMessage discovermsg = server.CreateMessage();
                    discovermsg.Write("Hey I just met you, I'm a server, so address me maybe");
                    Console.WriteLine(@"Auto Discovery Request");
                    server.SendDiscoveryResponse(discovermsg, inc.SenderEndPoint);
                    break;

                case NetIncomingMessageType.DebugMessage:
                case NetIncomingMessageType.ErrorMessage:
                case NetIncomingMessageType.WarningMessage:
                case NetIncomingMessageType.VerboseDebugMessage:
                    Console.WriteLine(@"---Debug---");
                    Console.WriteLine(inc.ReadString());
                    Console.WriteLine(@"---End---");
                    break;
            }
        }
开发者ID:JamieH,项目名称:Pictionary,代码行数:60,代码来源:Program.cs

示例5: Decode

 public void Decode(NetIncomingMessage im)
 {
     this.BlockID = im.ReadByte();
     this.X = im.ReadInt16();
     this.Y = im.ReadInt16();
     this.Z = im.ReadByte();
 }
开发者ID:Express50,项目名称:Bricklayer,代码行数:7,代码来源:BlockMessage.cs

示例6: readBytes

 public static void readBytes(NetIncomingMessage data, ref InputObject io)
 {
     data.ReadByte();
     Console.WriteLine(io.HorizontalAxis = data.ReadFloat());
     Console.WriteLine(io.VerticalAxis = data.ReadFloat());
     Console.WriteLine(io.AmingAngle = data.ReadFloat());
     Console.WriteLine(io.Buttons = data.ReadByte());
 }
开发者ID:Harlonlonmo,项目名称:Network-Game,代码行数:8,代码来源:InputParser.cs

示例7: Read

            public static PlayerInformation Read(NetIncomingMessage packet)
            {
                Byte slot = packet.ReadByte();
                TeamType team = (TeamType)packet.ReadByte();
                String callsign = packet.ReadString();
                String tag = packet.ReadString();

                return new PlayerInformation(slot, callsign, tag, team);
            }
开发者ID:aotis,项目名称:AngryTanks,代码行数:9,代码来源:Messages.cs

示例8: HandleEntityComponentNetworkMessage

 /// <summary>
 /// Handles an incoming entity component message
 /// </summary>
 /// <param name="message">Raw network message</param>
 /// <returns>An IncomingEntityComponentMessage object</returns>
 public IncomingEntityComponentMessage HandleEntityComponentNetworkMessage(NetIncomingMessage message)
 {
     var componentFamily = (ComponentFamily) message.ReadByte();
     var messageParams = new List<object>();
     while (message.Position < message.LengthBits)
     {
         switch ((NetworkDataType) message.ReadByte())
         {
             case NetworkDataType.d_enum:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_bool:
                 messageParams.Add(message.ReadBoolean());
                 break;
             case NetworkDataType.d_byte:
                 messageParams.Add(message.ReadByte());
                 break;
             case NetworkDataType.d_sbyte:
                 messageParams.Add(message.ReadSByte());
                 break;
             case NetworkDataType.d_ushort:
                 messageParams.Add(message.ReadUInt16());
                 break;
             case NetworkDataType.d_short:
                 messageParams.Add(message.ReadInt16());
                 break;
             case NetworkDataType.d_int:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_uint:
                 messageParams.Add(message.ReadUInt32());
                 break;
             case NetworkDataType.d_ulong:
                 messageParams.Add(message.ReadUInt64());
                 break;
             case NetworkDataType.d_long:
                 messageParams.Add(message.ReadInt64());
                 break;
             case NetworkDataType.d_float:
                 messageParams.Add(message.ReadFloat());
                 break;
             case NetworkDataType.d_double:
                 messageParams.Add(message.ReadDouble());
                 break;
             case NetworkDataType.d_string:
                 messageParams.Add(message.ReadString());
                 break;
             case NetworkDataType.d_byteArray:
                 int length = message.ReadInt32();
                 messageParams.Add(message.ReadBytes(length));
                 break;
         }
     }
     return new IncomingEntityComponentMessage(componentFamily, messageParams);
 }
开发者ID:Tri125,项目名称:space-station-14,代码行数:60,代码来源:EntityNetworkManager.cs

示例9: OnAdvancedNetworkMessage

 public override void OnAdvancedNetworkMessage(NetIncomingMessage msg)
 {
     if (msg.ReadByte() == 0)
     {
         this.lxLoot = new List<PreSeededLoot>();
         byte byCount = msg.ReadByte();
         for (int i = 0; i < (int)byCount; i++)
         {
             this.lxLoot.Add(new PreSeededLoot(msg.ReadUInt16(), (ItemCodex.ItemTypes)msg.ReadInt32(), new Vector2(msg.ReadFloat(), msg.ReadFloat())));
         }
     }
 }
开发者ID:ancientgods,项目名称:SoG,代码行数:12,代码来源:GigaSlimeMemoryBattleBagman.cs

示例10: Decode

 public void Decode(NetIncomingMessage im)
 {
     this.ServerName = im.ReadString();
     this.Description = im.ReadString();
     this.Intro = im.ReadString();
     this.Online = im.ReadByte();
     int roomsLength = im.ReadByte();
     for (int i = 0; i < roomsLength; i++)
     {
         Rooms.Add(new LobbySaveData(im.ReadString(), im.ReadInt16(), im.ReadString(), im.ReadByte(), im.ReadInt16(), im.ReadDouble()));
     }
 }
开发者ID:Express50,项目名称:Bricklayer,代码行数:12,代码来源:LobbyMessage.cs

示例11: ReadFromMessage

 public static NetObject ReadFromMessage(NetIncomingMessage message)
 {
     var type = (NetObjectType)message.ReadByte();
     var instance = (NetObject)Activator.CreateInstance(netObjectTypes[type]);
     instance.Read(message);
     return instance;
 }
开发者ID:Rohansi,项目名称:Programe,代码行数:7,代码来源:NetObject.Static.cs

示例12: Data

 private void Data(NetIncomingMessage inc)
 {
     var packetType = (PacketType) inc.ReadByte();
     var gameRoom = GetGameRoomById(inc.ReadString());
     var command = PacketFactory.GetCommand(packetType); 
     command.Run(_managerLogger, this,inc, null, gameRoom);
 }
开发者ID:paulushcgcj,项目名称:SpeedCodingNetworkGame,代码行数:7,代码来源:Server.cs

示例13: HandleData

        /// <summary>
        /// 
        /// </summary>
        /// <param name="incomingMsg"></param>
        public void HandleData(NetIncomingMessage incomingMsg)
        {
            MessageType messageType = (MessageType)incomingMsg.ReadByte();

            switch (messageType)
            {
                case MessageType.MsgState:
                    SendState();
                    break;

                case MessageType.MsgPlayerClientUpdate:
                    BroadcastUpdate(incomingMsg);
                    break;

                case MessageType.MsgDeath:
                    Die(incomingMsg);
                    break;

                case MessageType.MsgBeginShot:
                    Shoot(incomingMsg);
                    break;

                case MessageType.MsgEndShot:
                    EndShot(incomingMsg);
                    break;

                default:
                    break;
            }
        }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:34,代码来源:Player.cs

示例14: ReadArgument

 static object ReadArgument(NetIncomingMessage msg, Type type)
 {
     if (type == typeof(int))
     {
         return msg.ReadInt32();
     }
     else if (type == typeof(byte))
     {
         return msg.ReadByte();
     }
     else if (type == typeof(float))
     {
         return msg.ReadFloat();
     }
     else if (type == typeof(Vector3))
     {
         return NetworkUtils.ReadVector3(msg);
     }
     else if (type == typeof(Quaternion))
     {
         return NetworkUtils.ReadQuaternion(msg);
     }
     else if (type == typeof(string))
     {
         return msg.ReadString();
     }
     else
     {
         throw new Exception("Unsupported argument type " + type);
     }
 }
开发者ID:RainsSoft,项目名称:unity3d-fps-networking-prototype,代码行数:31,代码来源:NetworkRemoteCallReceiver.cs

示例15: LidgrenStatusChangeMessageContext

		public LidgrenStatusChangeMessageContext(NetIncomingMessage incomingMessage) 
			: base(incomingMessage)
		{
			LidgrenStatus = (NetConnectionStatus)incomingMessage.ReadByte();
			//Generate a Lidgren status message for dispatching
			GeneratedStatusMessage = new LidgrenStatusMessage(LidgrenStatus);
		}
开发者ID:HelloKitty,项目名称:GladNet2-Lidgren,代码行数:7,代码来源:LidgrenStatusChangeMessageContext.cs


注:本文中的Lidgren.Network.NetIncomingMessage.ReadByte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。