Deserialize() public method

public Deserialize ( BinaryReader reader ) : void
reader System.IO.BinaryReader
return void
Example #1
0
 public override void OnPacket(NetworkClient client, ProcessedPacket packet)
 {
     var cmd = new VMNetCommand();
     try {
         using (var reader = new BinaryReader(packet)) {
             cmd.Deserialize(reader);
         }
     } catch (Exception)
     {
         ClientsToDC.Add(client);
         return;
     }
     if (cmd.Type == VMCommandType.SimJoin)
     {
         if (((VMNetSimJoinCmd)cmd.Command).Version != VMNetSimJoinCmd.CurVer)
         {
             ClientsToDC.Add(client);
             return;
         }
         lock (UIDs)
         {
             UIDs.Add(client, ((VMNetSimJoinCmd)cmd.Command).SimID);
         }
     }
     SendCommand(cmd.Command);
 }
Example #2
0
        public void Deserialize(BinaryReader reader)
        {
            TickID = reader.ReadUInt32();
            RandomSeed = reader.ReadUInt64();

            Commands = new List<VMNetCommand>();
            int length = reader.ReadInt32();
            for (int i=0; i<length; i++)
            {
                var cmd = new VMNetCommand();
                cmd.Deserialize(reader);
                Commands.Add(cmd);
            }
        }
        public void Deserialize(BinaryReader reader)
        {
            TickID     = reader.ReadUInt32();
            RandomSeed = reader.ReadUInt64();

            Commands = new List <VMNetCommand>();
            int length = reader.ReadInt32();

            for (int i = 0; i < length; i++)
            {
                var cmd = new VMNetCommand();
                cmd.Deserialize(reader);
                Commands.Add(cmd);
            }
        }
Example #4
0
        public override void OnPacket(NetworkClient client, ProcessedPacket packet)
        {
            var cmd = new VMNetCommand();
            try {
                using (var reader = new BinaryReader(packet)) {
                    cmd.Deserialize(reader);
                }
            } catch (Exception)
            {
                ClientsToDC.Add(client);
                return;
            }

            if (cmd.Type == VMCommandType.SimJoin)
            {
                if (SandboxBans.Contains(client.RemoteIP))
                {
                    SendGenericMessage(client, "Banned", "You have been banned from this sandbox server!");
                    ClientsToDC.Add(client);
                    return;
                }
                else if (((VMNetSimJoinCmd)cmd.Command).Version != VMNetSimJoinCmd.CurVer)
                {
                    SendGenericMessage(client, "Version Mismatch", "Your game version does not match the server's. Please update your game.");
                    ClientsToDC.Add(client);
                    return;
                }

                ((VMNetSimJoinCmd)cmd.Command).Ticket = client.RemoteIP+":"+((VMNetSimJoinCmd)cmd.Command).Name;
                ((VMNetSimJoinCmd)cmd.Command).Client = client; //remember client so we can bind it to persist id later
                SendCommand(cmd.Command); //just go for it. will start the avatar retrieval process.
                return;
            }
            else if (cmd.Type == VMCommandType.RequestResync)
            {
                lock (ClientsToSync)
                {
                    //todo: throttle
                    ClientsToSync.Add(client);
                }
            }

            lock (ClientToUID)
            {
                if (!ClientToUID.ContainsKey(client)) return; //client hasn't registered yet
                cmd.Command.ActorUID = ClientToUID[client];
            }
            SendCommand(cmd.Command);
        }