Ejemplo n.º 1
0
        public static Datagram ResolveResponse(byte[] rawDatagram)
        {
            Datagram result = null;

            Datagram temp = new DatagramResponse();

            temp.Parse(rawDatagram);

            if (DatagramResolver.HeadTag.SequenceEqual(temp.Head))
            {
                if (temp.CommandCode.SequenceEqual(HeartbeatResponse.FixCommandCode) &&
                    rawDatagram.Length == HeartbeatResponse.Length)
                {
                    result = new HeartbeatResponse();
                }

                if (temp.CommandCode.SequenceEqual(LoginResponse.FixCommandCode) &&
                    rawDatagram.Length == LoginResponse.Length)
                {
                    result = new LoginResponse();
                }

                if (temp.CommandCode.SequenceEqual(BlacklistQueryResponse.FixCommandCode) &&
                    rawDatagram.Length == BlacklistQueryResponse.Length)
                {
                    result = new BlacklistQueryResponse();
                }

                if (temp.CommandCode.SequenceEqual(BlacklistDownloadResponse.FixCommandCode) &&
                    rawDatagram.Length == BlacklistDownloadResponse.Length)
                {
                    result = new BlacklistDownloadResponse();
                }

                if (temp.CommandCode.SequenceEqual(CurrencyResponse.FixCommandCode) &&
                    rawDatagram.Length == CurrencyResponse.Length)
                {
                    result = new CurrencyResponse();
                }

                if (result != null)
                {
                    result.Parse(rawDatagram);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static Datagram ResolveResponse(byte[] rawDatagram)
        {
            Datagram result = null;

            Datagram temp = new DatagramResponse();

            temp.Parse(rawDatagram);

            if (DatagramResolver.HeadTag.SequenceEqual(temp.Head))
            {
                if (temp.CommandCode.SequenceEqual(HeartbeatResponse.FixCommandCode) &&
                    rawDatagram.Length == HeartbeatResponse.Length)
                {
                    result = new HeartbeatResponse();
                }

                if (temp.CommandCode.SequenceEqual(LoginResponse.FixCommandCode) &&
                    rawDatagram.Length == LoginResponse.Length)
                {
                    result = new LoginResponse();
                }

                if (temp.CommandCode.SequenceEqual(BlacklistQueryResponse.FixCommandCode) &&
                   rawDatagram.Length == BlacklistQueryResponse.Length)
                {
                    result = new BlacklistQueryResponse();
                }

                if (temp.CommandCode.SequenceEqual(BlacklistDownloadResponse.FixCommandCode) &&
                   rawDatagram.Length == BlacklistDownloadResponse.Length)
                {
                    result = new BlacklistDownloadResponse();
                }

                if (temp.CommandCode.SequenceEqual(CurrencyResponse.FixCommandCode) &&
                    rawDatagram.Length == CurrencyResponse.Length)
                {
                    result = new CurrencyResponse();
                }

                if (result != null)
                {
                    result.Parse(rawDatagram);
                }
            }

            return result;
        }