예제 #1
0
파일: Client.cs 프로젝트: gmriggs/ACE.Diag
        /// <summary>
        /// Only handles response packets atm?
        /// </summary>
        /// <param name="responseBytes">The server packet sent as a response from a previous request</param>
        /// <returns>The parsed packet object</returns>
        public Packet.Packet GetPacket(byte[] responseBytes)
        {
            var packetType = (PacketType)responseBytes[0];

            Packet.Packet packet = null;

            switch (packetType)
            {
            case PacketType.ConnectResponse:
                packet = new ConnectResponse(responseBytes);
                break;

            case PacketType.PingRequest:
                packet = new PingRequest(responseBytes);
                break;

            case PacketType.GameState:
                packet = new Packet.GameState(responseBytes);
                break;

            case PacketType.GameStateDiff:
                packet = new GameStateDiff(responseBytes);
                break;
            }

            ShowResponse(responseBytes);

            return(packet);
        }
예제 #2
0
파일: Client.cs 프로젝트: gmriggs/ACE.Diag
        public void ShowResponse(byte[] responseBytes)
        {
            var packetType = (PacketType)responseBytes[0];

            Console.WriteLine("Response packet type = " + packetType);

            switch (packetType)
            {
            case PacketType.ConnectResponse:
                var packet = new ConnectResponse(responseBytes);
                Console.WriteLine("Connect response type = " + packet.ConnectResponseType);
                Console.WriteLine("Reason = " + packet.Reason);
                break;

            case PacketType.PingRequest:
                var pingRequest = new PingRequest(responseBytes);
                Console.WriteLine("Ping request: " + pingRequest.Random);
                break;

            case PacketType.GameState:
                var gameState = new Packet.GameState(responseBytes);
                Console.WriteLine(string.Format("Game state packet received ({0} bytes, {1} compressed)", gameState.State.StateBytes.Length, gameState.State.StateBytesCompressed.Length));
                break;

            case PacketType.GameStateDiff:
                var gameStateDiff = new GameStateDiff(responseBytes);
                Console.WriteLine(string.Format("Game state diff packet received"));
                break;
            }
        }