public static IRequest Serilize(byte[] rawRequest)
        {
            IRequest request;

            if (rawRequest.Length < 1)
            {
                return(null);
            }

            switch ((QRPacketType)rawRequest[0])
            {
            case QRPacketType.AvaliableCheck:
                request = new AvaliableRequest(rawRequest);
                break;

            //verify challenge to check game server is real or fake;
            //after verify we can add game server to server list
            case QRPacketType.Challenge:
                request = new ChallengeRequest(rawRequest);
                break;

            case QRPacketType.HeartBeat:
                request = new HeartBeatRequest(rawRequest);
                break;

            case QRPacketType.KeepAlive:
                request = new KeepAliveRequest(rawRequest);
                break;

            case QRPacketType.EchoResponse:
                request = new QRRequestBase(rawRequest);
                break;

            case QRPacketType.ClientMessageACK:
                request = new QRRequestBase(rawRequest);
                break;

            default:
                LogWriter.UnknownDataRecieved(rawRequest);
                request = null;
                break;
            }

            if (request == null)
            {
                return(null);
            }

            if (!(bool)request.Parse())
            {
                LogWriter.ToLog(LogEventLevel.Error, ErrorMessage.GetErrorMessage(QRErrorCode.Parse));
                return(null);
            }

            return(request);
        }
        public void AvaliableTest()
        {
            var rawRequest = new byte[] {
                0x09,                                     //packet type
                0x00, 0x00, 0x00, 0x00,                   //instant key
                0x09, 0x00, 0x00, 0x00, 0x00,             //prefix
                0x67, 0x61, 0x6D, 0x65, 0x73, 0x70, 0x79, //gamename
                0x00
            };
            var request = new AvaliableRequest(rawRequest);

            request.Parse();
            Assert.Equal(RequestType.AvaliableCheck, request.CommandName);
            Assert.Equal((uint)0, request.InstantKey);
        }
 public AvaliableResponse(AvaliableRequest request) : base(request, null)
 {
 }
 public AvailableHandler(ISession session, IRequest request) : base(session, request)
 {
     _request = (AvaliableRequest)request;
 }