Deserialize() public method

public Deserialize ( BinaryReader reader ) : void
reader System.IO.BinaryReader
return void
コード例 #1
0
ファイル: VMServerDriver.cs プロジェクト: Daribon/FreeSO
 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);
 }
コード例 #2
0
ファイル: VMNetTick.cs プロジェクト: RHY3756547/FreeSO
        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);
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
ファイル: VMServerDriver.cs プロジェクト: RHY3756547/FreeSO
        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);
        }