예제 #1
0
        /**
         * Reads the next token from the stream and returns it.
         *
         * @param	BinaryStream	Stream used to serialize from
         * @param	InNetworkStream	Network stream this token belongs to
         * @return	Token serialized
         */
        public static TokenBase ReadNextToken(BinaryReader BinaryStream, NetworkStream InNetworkStream)
        {
            TokenBase SerializedToken = null;

            ETokenTypes TokenType = (ETokenTypes)BinaryStream.ReadByte();

            // Handle token specific serialization.
            switch (TokenType)
            {
            case ETokenTypes.FrameMarker:
                SerializedToken = new TokenFrameMarker(BinaryStream);
                break;

            case ETokenTypes.SocketSendTo:
                SerializedToken = new TokenSocketSendTo(BinaryStream);
                break;

            case ETokenTypes.SendBunch:
                SerializedToken = new TokenSendBunch(BinaryStream);
                break;

            case ETokenTypes.SendRPC:
                SerializedToken = new TokenSendRPC(BinaryStream);
                break;

            case ETokenTypes.ReplicateActor:
                SerializedToken = new TokenReplicateActor(BinaryStream);
                break;

            case ETokenTypes.ReplicateProperty:
                SerializedToken = new TokenReplicateProperty(BinaryStream);
                break;

            case ETokenTypes.EndOfStreamMarker:
                SerializedToken = new TokenEndOfStreamMarker();
                break;

            case ETokenTypes.Event:
                SerializedToken = new TokenEvent(BinaryStream);
                break;

            case ETokenTypes.RawSocketData:
                SerializedToken = new TokenRawSocketData(BinaryStream);
                break;

            default:
                throw new InvalidDataException();
            }

            TokenTypeStats[(int)TokenType]++;
            SerializedToken.NetworkStream = InNetworkStream;
            SerializedToken.TokenType     = TokenType;
            return(SerializedToken);
        }
예제 #2
0
        /**
         * Reads the next token from the stream and returns it.
         *
         * @param	BinaryStream	Stream used to serialize from
         * @param	InNetworkStream	Network stream this token belongs to
         * @return	Token serialized
         */
        public static TokenBase ReadNextToken(BinaryReader BinaryStream, NetworkStream InNetworkStream)
        {
            TokenBase SerializedToken = null;

            ETokenTypes TokenType = (ETokenTypes)BinaryStream.ReadByte();

            // Handle token specific serialization.
            switch (TokenType)
            {
            case ETokenTypes.FrameMarker:
                SerializedToken = new TokenFrameMarker(BinaryStream);
                break;

            case ETokenTypes.SocketSendTo:
                SerializedToken = new TokenSocketSendTo(BinaryStream);
                break;

            case ETokenTypes.SendBunch:
                SerializedToken = new TokenSendBunch(BinaryStream);
                break;

            case ETokenTypes.SendRPC:
                SerializedToken = new TokenSendRPC(BinaryStream);
                break;

            case ETokenTypes.ReplicateActor:
                SerializedToken = new TokenReplicateActor(BinaryStream);
                break;

            case ETokenTypes.ReplicateProperty:
                SerializedToken = new TokenReplicateProperty(BinaryStream);
                break;

            case ETokenTypes.EndOfStreamMarker:
                SerializedToken = new TokenEndOfStreamMarker();
                break;

            case ETokenTypes.Event:
                SerializedToken = new TokenEvent(BinaryStream);
                break;

            case ETokenTypes.RawSocketData:
                SerializedToken = new TokenRawSocketData(BinaryStream);
                break;

            case ETokenTypes.SendAck:
                SerializedToken = new TokenSendAck(BinaryStream);
                break;

            case ETokenTypes.WritePropertyHeader:
                SerializedToken = new TokenWritePropertyHeader(BinaryStream);
                break;

            case ETokenTypes.ExportBunch:
                SerializedToken = new TokenExportBunch(BinaryStream);
                break;

            case ETokenTypes.MustBeMappedGuids:
                SerializedToken = new TokenMustBeMappedGuids(BinaryStream);
                break;

            case ETokenTypes.BeginContentBlock:
                SerializedToken = new TokenBeginContentBlock(BinaryStream);
                break;

            case ETokenTypes.EndContentBlock:
                SerializedToken = new TokenEndContentBlock(BinaryStream);
                break;

            case ETokenTypes.WritePropertyHandle:
                SerializedToken = new TokenWritePropertyHandle(BinaryStream);
                break;

            case ETokenTypes.NameReference:
                SerializedToken = new TokenNameReference(BinaryStream);
                break;

            case ETokenTypes.ConnectionReference:
                SerializedToken = new TokenConnectionReference(BinaryStream);
                break;

            case ETokenTypes.ConnectionChange:
                SerializedToken = new TokenConnectionChanged(BinaryStream);
                break;

            default:
                throw new InvalidDataException();
            }

            TokenTypeStats[(int)TokenType]++;
            SerializedToken.NetworkStream = InNetworkStream;
            SerializedToken.TokenType     = TokenType;

            SerializedToken.ConnectionIndex = InNetworkStream.CurrentConnectionIndex;
            return(SerializedToken);
        }
예제 #3
0
파일: Tokens.cs 프로젝트: xiangyuan/Unreal4
		/**
		 * Reads the next token from the stream and returns it.
		 * 
		 * @param	BinaryStream	Stream used to serialize from
		 * @param	InNetworkStream	Network stream this token belongs to
		 * @return	Token serialized
		 */
		public static TokenBase ReadNextToken(BinaryReader BinaryStream, NetworkStream InNetworkStream)
		{
			TokenBase SerializedToken = null;

			ETokenTypes TokenType = (ETokenTypes) BinaryStream.ReadByte();
			// Handle token specific serialization.
			switch( TokenType )
			{
				case ETokenTypes.FrameMarker:
					SerializedToken = new TokenFrameMarker( BinaryStream );
					break;
				case ETokenTypes.SocketSendTo:
					SerializedToken = new TokenSocketSendTo( BinaryStream );
					break;
				case ETokenTypes.SendBunch:
					SerializedToken = new TokenSendBunch( BinaryStream );
					break;
				case ETokenTypes.SendRPC:
					SerializedToken = new TokenSendRPC( BinaryStream );
					break;
				case ETokenTypes.ReplicateActor:
					SerializedToken = new TokenReplicateActor( BinaryStream );
					break;
				case ETokenTypes.ReplicateProperty:
					SerializedToken = new TokenReplicateProperty( BinaryStream );
					break;
				case ETokenTypes.EndOfStreamMarker:
					SerializedToken = new TokenEndOfStreamMarker();
					break;
				case ETokenTypes.Event:
					SerializedToken = new TokenEvent( BinaryStream );
					break;
				case ETokenTypes.RawSocketData:
					SerializedToken = new TokenRawSocketData( BinaryStream );
					break;
				case ETokenTypes.SendAck:
					SerializedToken = new TokenSendAck( BinaryStream );
					break;
				case ETokenTypes.WritePropertyHeader:
					SerializedToken = new TokenWritePropertyHeader( BinaryStream );
					break;
				case ETokenTypes.ExportBunch:
					SerializedToken = new TokenExportBunch( BinaryStream );
					break;
				case ETokenTypes.MustBeMappedGuids:
					SerializedToken = new TokenMustBeMappedGuids( BinaryStream );
					break;
				case ETokenTypes.BeginContentBlock:
					SerializedToken = new TokenBeginContentBlock( BinaryStream );
					break;
				case ETokenTypes.EndContentBlock:
					SerializedToken = new TokenEndContentBlock( BinaryStream );
					break;
				case ETokenTypes.WritePropertyHandle:
					SerializedToken = new TokenWritePropertyHandle( BinaryStream );
					break;
				default:
					throw new InvalidDataException();
			}

			TokenTypeStats[(int)TokenType]++;
			SerializedToken.NetworkStream = InNetworkStream;
			SerializedToken.TokenType = TokenType;
			return SerializedToken;
		}