ReadUInt32() public method

Reads an 32 bit unsigned integer written using Write(UInt32)
public ReadUInt32 ( ) : UInt32
return System.UInt32
Beispiel #1
0
 public void R(NetIncomingMessage im)
 {
     Operat          = im.ReadByte();
     UserId          = im.ReadUInt32();
     if (Operat == Add || Operat == Changed)
     {
         Tag         = im.ReadUInt32();
         if (GameMessageHelper.Is_Changed(Tag, GameMessageHelper.POSITION_TAG))
         {
             X       = im.ReadFloat();
             Y       = im.ReadFloat();
         }
         if (GameMessageHelper.Is_Changed(Tag, GameMessageHelper.RADIUS_TAG))
         {
             Radius  = im.ReadInt32();
         }
         if (GameMessageHelper.Is_Changed(Tag, GameMessageHelper.COLOR_TAG))
         {
             Color   = im.ReadUInt32();
         }
         if (GameMessageHelper.Is_Changed(Tag, GameMessageHelper.NAME_TAG))
         {
             Name    = im.ReadString();
         }
     }
 }
 public void R(NetIncomingMessage im)
 {
     Uid         = im.ReadUInt32();
     X           = im.ReadInt32();
     Y           = im.ReadInt32();
     SpriteId    = im.ReadUInt32();
 }
			public override void DataReceived ( NetCommand command, NetIncomingMessage msg )
			{
				if (command==NetCommand.Snapshot) {
					
					var frame		=	msg.ReadUInt32();
					var prevFrame	=	msg.ReadUInt32();
					var ackCmdID	=	msg.ReadUInt32();
					var serverTicks	=	msg.ReadInt64();
					var size		=	msg.ReadInt32();

					//Log.Warning("{0}", offsetTicks );

					if (prevFrame!=0) {
						Log.Warning("Bad initial snapshot. Previous frame does not equal zero.");
						return;
					}
					if (ackCmdID!=0) {
						Log.Warning("Bad command ID {0}. Command ID for initial snapshot must be zero.", ackCmdID);
						return;
					}

					//	read snapshot :
					var snapshot	=	NetDeflate.Decompress( msg.ReadBytes(size) );

					//	initial snapshot contains atom table :
					gameClient.Atoms	=	new AtomCollection( msg );


					gameClient.SetState( new Active( gameClient, frame, snapshot, serverTicks ) );
				}

				if (command==NetCommand.Notification) {
					gameClient.FeedNotification( msg.ReadString() );
				}
			}
Beispiel #4
0
 public void R(NetIncomingMessage im)
 {
     Operat = im.ReadByte();
     BallId = im.ReadUInt32();
     if(Operat == Add)
     {
         X       = im.ReadFloat();
         Y       = im.ReadFloat();
         Radius  = im.ReadInt32();
         Color   = im.ReadUInt32();
     }
 }
Beispiel #5
0
 public void R(NetIncomingMessage im)
 {
     int Count = im.ReadInt32();
     for(int i = 0; i < Count; ++i)
     {
         uint uid = im.ReadUInt32();
         float x = im.ReadFloat();
         float y = im.ReadFloat();
         int r = im.ReadInt32();
         uint color = im.ReadUInt32();
         FixedList.Add(Tuple.Create<uint, float, float, int, uint>(uid, x, y, r, color));
     }
 }
Beispiel #6
0
        public static GameStateDelta ReadDelta(NetIncomingMessage message)
        {
            uint sequence = message.ReadUInt32();
            uint fromSequence = message.ReadUInt32();
            int length = message.ReadInt32();
            byte[] bytes;
            message.ReadBytes(length, out bytes);

            var delta = new GameStateDelta(bytes);
            delta.Sequence = sequence;
            delta.FromSequence = fromSequence;
            return delta;
        }
Beispiel #7
0
 public void R(NetIncomingMessage im)
 {
     int Count = im.ReadInt32();
     for (int i = 0; i < Count; ++i)
     {
         uint uid    = im.ReadUInt32();
         float x     = im.ReadFloat();
         float y     = im.ReadFloat();
         int r     = im.ReadInt32();
         uint color  = im.ReadUInt32();
         string name = im.ReadString();
         PLayerList.Add(Tuple.Create<uint, float, float, int, uint, string>(uid, x, y, r, color, name));
     }
 }
 public override void ReadPayload(NetIncomingMessage message)
 {
     base.ReadPayload(message);
     Image = message.ReadBytes(message.ReadInt32());
     Number = message.ReadUInt32();
     SendIndex = message.ReadInt32();
 }
        public override unsafe bool Decrypt(NetIncomingMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            int unEncLenBits = (int)message.ReadUInt32();
            int byteLen      = NetBitWriter.BytesForBits(unEncLenBits);
            var result       = message.StoragePool.Rent(byteLen);

            // TODO: create stream that takes Memory<byte> overload
            fixed(byte *msgPtr = message.GetBuffer())
            {
                using var ms        = new UnmanagedMemoryStream(msgPtr + 4, message.ByteLength - 4);
                using var decryptor = Algorithm.CreateDecryptor();
                using var cs        = new CryptoStream(ms, decryptor, CryptoStreamMode.Read);
                cs.Read(result, 0, byteLen);
            }

            message.SetBuffer(result, true);
            message.BitLength   = unEncLenBits;
            message.BitPosition = 0;

            return(true);
        }
 public override void ReadPayload(NetIncomingMessage message)
 {
     base.ReadPayload(message);
     Region = new Rectangle(message.ReadInt32(), message.ReadInt32(), message.ReadInt32(), message.ReadInt32());
     Number = message.ReadUInt32();
     FinalLength = message.ReadInt32();
 }
Beispiel #11
0
        /// <summary>
        /// Writes a <see cref="NetIncomingMessage"/> buffer into the BitStream.
        /// </summary>
        /// <param name="source">The <see cref="NetIncomingMessage"/> who's contents will be copied to this BitStream.</param>
        public void Write(NetIncomingMessage source)
        {
#if DEBUG
            var startBSPos = PositionBits;
            var startMsgPos = (int)source.Position;
#endif

            // Read full 32-bit integers
            while (source.LengthBits - source.Position >= _bitsInt)
            {
                var v = source.ReadUInt32();
                Write(v);
            }

            // Read full 8-bit integers
            while (source.LengthBits - source.Position >= _bitsByte)
            {
                var v = source.ReadByte();
                Write(v);
            }

            // Read the remaining bits
            while (source.LengthBits > source.Position)
            {
                var v = source.ReadBoolean();
                Write(v);
            }

            Debug.Assert(source.Position == source.LengthBits);

#if DEBUG
            Debug.Assert(PositionBits - startBSPos == source.LengthBits - startMsgPos);
#endif
        }
Beispiel #12
0
 public void R(NetIncomingMessage im)
 {
     if(PlayerPack == null)
     {
         PlayerPack = new List<Tuple<uint, int, int, bool, uint>>();
     }
     int l = im.ReadInt32();
     for(int i = 0; i < l; ++i)
     {
         var id      = im.ReadUInt32();
         var x       = im.ReadInt32();
         var y       = im.ReadInt32();
         var alive   = im.ReadBoolean();
         var sid     = im.ReadUInt32();
         PlayerPack.Add(Tuple.Create<uint, int, int, bool, uint>(id, x, y, alive, sid));
     }
 }
 public static void readBytes(NetIncomingMessage data, ClientSprite cs)
 {
     data.ReadByte();
     cs.ID = data.ReadUInt32();
     cs.SpriteID = (SpriteIDs)data.ReadUInt16();
     cs.Position = new Microsoft.Xna.Framework.Vector2(data.ReadFloat(),data.ReadFloat());
     cs.Rotation = data.ReadFloat();
 }
Beispiel #14
0
 public void ReceiveChunkData(NetIncomingMessage message)
 {
     for (int i = 0; i < Tiles.Length; ++i)
     {
         Tile tile = (Tile)message.ReadUInt32();
         Tiles[i] = tile;
     }
 }
Beispiel #15
0
 public void R(NetIncomingMessage im)
 {
     int Count = im.ReadInt32();
     for(int i = 0; i < Count; ++i)
     {
         uint id = im.ReadUInt32();
         int mark = im.ReadInt32();
         MarkList.Add(new KeyValuePair<uint, int>(id, mark));
     }
 }
 /// <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);
 }
Beispiel #17
0
 public void Read(NetIncomingMessage im)
 {
     if (ProcessList == null)
     {
         ProcessList = new List<Tuple<uint, string>>();
     }
     int count = im.ReadInt32();
     for (int i = 0; i < count; ++i)
     {
         uint pid    = im.ReadUInt32();
         string name = im.ReadString();
         ProcessList.Add(Tuple.Create<uint, string>(pid, name));
     }
 }
        public void deserialize(NetIncomingMessage inMsg)
        {
            targetFrame = inMsg.ReadUInt32();
            orderList.Capacity = inMsg.ReadInt32();

            for (int i = 0; i < orderList.Capacity; i++)
            {
                int orderID = inMsg.ReadInt32();
                Order newOrder = (Order)Activator.CreateInstance(OrderRegister.instance.idToOrder(orderID));
                newOrder.deserialize(inMsg);

                orderList.Add(newOrder);
            }
        }
Beispiel #19
0
 public void Read(NetIncomingMessage im)
 {
     if (FileInfoList == null)
     {
         FileInfoList = new List<Tuple<string, uint, bool>>();
     }
     int ListCount = im.ReadInt32();
     for (int i = 0; i < ListCount; ++i)
     {
         string Name     = im.ReadString();
         uint Size       = im.ReadUInt32();
         bool IsDire     = im.ReadBoolean();
         FileInfoList.Add(Tuple.Create<string, uint, bool>(Name, Size, IsDire));
     }
 }
Beispiel #20
0
 public void R(NetIncomingMessage im)
 {
     Operat      = im.ReadByte();
     if(Operat == GroupUp)
     {
         Radius  = im.ReadInt32();
     }
     else if(Operat == Born)
     {
         X = im.ReadFloat();
         Y = im.ReadFloat();
         Radius = im.ReadInt32();
         Color = im.ReadUInt32();
     }
 }
        public override bool Decrypt(NetIncomingMessage msg)
        {
            int unEncLenBits = (int)msg.ReadUInt32();

            var ms = new MemoryStream(msg.m_data, 4, msg.LengthBytes - 4);
            var cs = GetDecryptStream(ms);

            var result = m_peer.GetStorage(unEncLenBits);
            cs.Read(result, 0, NetUtility.BytesToHoldBits(unEncLenBits));
            cs.Close();

            // TODO: recycle existing msg

            msg.m_data = result;
            msg.m_bitLength = unEncLenBits;

            return true;
        }
		public override bool Decrypt(NetIncomingMessage msg)
		{
			int unEncLenBits = (int)msg.ReadUInt32();

			var ms = new MemoryStream(msg.m_data, 4, msg.LengthBytes - 4);
			var cs = GetDecryptStream(ms);

			var result = m_peer.GetStorage(unEncLenBits);
			cs.Read(result, 0, NetUtility.BytesToHoldBits(unEncLenBits));
			cs.Close();

			// TODO: recycle existing msg

			msg.m_data = result;
			msg.m_bitLength = unEncLenBits;

			return true;
		}
Beispiel #23
0
    public void RecommendationReceived(NetIncomingMessage inMsg)
    {
        Debug.Log("RecommendationReceived");

        int count = inMsg.ReadInt32();
        string[] names = new string[count];
        uint[][] participants = new uint[count][];

        for (int i = 0; i < count; i++)
        {
            names[i] = inMsg.ReadString();
            int numParticipants = inMsg.ReadInt32();
            participants[i] = new uint[numParticipants];
            for (int j = 0; j < numParticipants; j++)
                participants[i][j] = inMsg.ReadUInt32();
        }

        this.Runner.ReceivedCandidates(names, participants);
    }
		public override bool Decrypt(NetIncomingMessage msg)
		{
			int unEncLenBits = (int)msg.ReadUInt32();

			var ms = new MemoryStream(msg.m_data, 4, msg.LengthBytes - 4);
			var cs = new CryptoStream(ms, m_algorithm.CreateDecryptor(), CryptoStreamMode.Read);

			var byteLen = NetUtility.BytesToHoldBits(unEncLenBits);
			var result = m_peer.GetStorage(byteLen);
			cs.Read(result, 0, byteLen);
			cs.Close();

			// TODO: recycle existing msg

			msg.m_data = result;
			msg.m_bitLength = unEncLenBits;
			msg.m_readPosition = 0;

			return true;
		}
        public override bool Decrypt(NetIncomingMessage msg)
        {
            int unEncLenBits = (int)msg.ReadUInt32();

            var ms = new MemoryStream(msg.m_data, 4, msg.LengthBytes - 4);
            var cs = new CryptoStream(ms, m_algorithm.CreateDecryptor(), CryptoStreamMode.Read);

            var result = m_peer.GetStorage(unEncLenBits);

            cs.Read(result, 0, NetUtility.BytesToHoldBits(unEncLenBits));
            cs.Close();

            // TODO: recycle existing msg

            msg.m_data         = result;
            msg.m_bitLength    = unEncLenBits;
            msg.m_readPosition = 0;

            return(true);
        }
Beispiel #26
0
 public void R(NetIncomingMessage im)
 {
     Uid = im.ReadUInt32();
 }
Beispiel #27
0
 public void Read(NetIncomingMessage im)
 {
     CommandId = im.ReadUInt32();
 }
Beispiel #28
0
 public void HandleAdminMessage(NetMessage adminMsgType, NetIncomingMessage messageBody)
 {
     switch (adminMsgType)
     {
         case NetMessage.RequestAdminLogin:
             UserInterfaceManager.DisposeAllComponents<AdminPasswordDialog>(); //Remove old ones.
             UserInterfaceManager.AddComponent(new AdminPasswordDialog(new Size(200, 50), NetworkManager,
                                                                       ResourceManager)); //Create a new one.
             break;
         case NetMessage.RequestAdminPlayerlist:
             UserInterfaceManager.DisposeAllComponents<AdminPlayerPanel>();
             UserInterfaceManager.AddComponent(new AdminPlayerPanel(new Size(600, 200), NetworkManager,
                                                                    ResourceManager, messageBody));
             break;
         case NetMessage.RequestBanList:
             var banList = new Banlist();
             int entriesCount = messageBody.ReadInt32();
             for (int i = 0; i < entriesCount; i++)
             {
                 string ipAddress = messageBody.ReadString();
                 string reason = messageBody.ReadString();
                 bool tempBan = messageBody.ReadBoolean();
                 uint minutesLeft = messageBody.ReadUInt32();
                 var entry = new BanEntry
                                 {
                                     ip = ipAddress,
                                     reason = reason,
                                     tempBan = tempBan,
                                     expiresAt = DateTime.Now.AddMinutes(minutesLeft)
                                 };
                 banList.List.Add(entry);
             }
             UserInterfaceManager.DisposeAllComponents<AdminUnbanPanel>();
             UserInterfaceManager.AddComponent(new AdminUnbanPanel(new Size(620, 200), banList, NetworkManager,
                                                                   ResourceManager));
             break;
     }
 }
Beispiel #29
0
 /// <summary>
 /// Reads the transport into the contents of this type.
 /// </summary>
 public void ReadPayload(NetIncomingMessage message)
 {
     Image = message.ReadBytes(message.ReadInt32());
     Region = new Rectangle(message.ReadInt32(), message.ReadInt32(), message.ReadInt32(), message.ReadInt32());
     Number = message.ReadUInt32();
 }
 private List<object> UnPackParams(NetIncomingMessage message)
 {
     var messageParams = new List<object>();
     while (message.Position < message.LengthBits)
     {
         switch ((NetworkDataType) message.ReadByte())
         {
             case NetworkDataType.d_enum:
                 messageParams.Add(message.ReadInt32()); //Cast from int, because enums are ints.
                 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 messageParams;
 }
Beispiel #31
0
 public void R(NetIncomingMessage im)
 {
     Uid     = im.ReadUInt32();
     Width   = im.ReadInt32();
     Height  = im.ReadInt32();
 }
Beispiel #32
0
 public void HandleStateAck(NetIncomingMessage msg)
 {
     uint sequence = msg.ReadUInt32();
     IoCManager.Resolve<IGameStateManager>().Ack(msg.SenderConnection.RemoteUniqueIdentifier, sequence);
     //LogManager.Log("State Acked: " + sequence + " by client " + msg.SenderConnection.RemoteUniqueIdentifier + ".");
 }
Beispiel #33
0
 /// <summary>
 /// Reads a full gamestate from a NetIncomingMessage
 /// </summary>
 /// <param name="message">NetIncomingMessage that contains the state data</param>
 /// <returns></returns>
 public static GameState ReadStateMessage(NetIncomingMessage message)
 {
     uint sequence = message.ReadUInt32();
     int length = message.ReadInt32();
     byte[] stateData = Decompress(message.ReadBytes(length));
     using (var stateStream = new MemoryStream(stateData))
         return (GameState) Serializer.Deserialize(stateStream);
 }