Ejemplo n.º 1
0
        public bool Read(ByteArrayReaderWriter stream, int length, ulong protocolID)
        {
            if (length != 13 + 8 + 8 + 8 + Defines.NETCODE_CONNECT_TOKEN_PRIVATE_BYTES)
            {
                return(false);
            }

            char[] vInfo = new char[Defines.NETCODE_VERSION_INFO_BYTES];
            stream.ReadASCIICharsIntoBuffer(vInfo, Defines.NETCODE_VERSION_INFO_BYTES);
            if (!MiscUtils.MatchChars(vInfo, Defines.NETCODE_VERSION_INFO_STR))
            {
                return(false);
            }

            if (stream.ReadUInt64() != protocolID)
            {
                return(false);
            }

            this.Expiration        = stream.ReadUInt64();
            this.TokenSequenceNum  = stream.ReadUInt64();
            this.ConnectTokenBytes = BufferPool.GetBuffer(Defines.NETCODE_CONNECT_TOKEN_PRIVATE_BYTES);
            stream.ReadBytesIntoBuffer(this.ConnectTokenBytes, Defines.NETCODE_CONNECT_TOKEN_PRIVATE_BYTES);

            return(true);
        }
Ejemplo n.º 2
0
        public bool Read(ByteArrayReaderWriter reader)
        {
            char[] vInfo = new char[13];
            reader.ReadASCIICharsIntoBuffer(vInfo, 13);
            if (!MiscUtils.MatchChars(vInfo, Defines.NETCODE_VERSION_INFO_STR))
            {
                return(false);
            }

            ProtocolID = reader.ReadUInt64();

            CreateTimestamp          = reader.ReadUInt64();
            ExpireTimestamp          = reader.ReadUInt64();
            ConnectTokenSequence     = reader.ReadUInt64();
            PrivateConnectTokenBytes = reader.ReadBytes(Defines.NETCODE_CONNECT_TOKEN_PRIVATE_BYTES);

            int numServers = (int)reader.ReadUInt32();

            if (numServers < 1 || numServers > Defines.MAX_SERVER_ADDRESSES)
            {
                return(false);
            }

            this.ConnectServers = new ConnectTokenServerEntry[numServers];
            for (int i = 0; i < numServers; i++)
            {
                this.ConnectServers[i] = new ConnectTokenServerEntry();
                this.ConnectServers[i].ReadData(reader);
            }

            ClientToServerKey = reader.ReadBytes(32);
            ServerToClientKey = reader.ReadBytes(32);
            TimeoutSeconds    = reader.ReadUInt32();

            return(true);
        }