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

            Datagram temp = new DatagramRequest();

            temp.Parse(rawDatagram);

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

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

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

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

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

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

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

            Datagram temp = new DatagramRequest();

            temp.Parse(rawDatagram);

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

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

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

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

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

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

            return(result);
        }
Ejemplo n.º 3
0
        public void SendBlacklist()
        {
            if (this.IsConnected)
            {
                if (this.IsFinishDownloadBlacklist)
                {
                    BlacklistQueryRequest blacklistQuery = new BlacklistQueryRequest();

                    blacklistQuery.DeviceNumber = this.DeviceNumberHex;
                    blacklistQuery.BlacklistVersion = new byte[] { 0x0C, 0x05, 0x10 };
                    blacklistQuery.Foot = blacklistQuery.BuildFoot();

                    this.LocalSocket.BeginSend(blacklistQuery.BuildFull());
                }

                else
                {
                    BlacklistDownloadRequest blacklistDownload = new BlacklistDownloadRequest();

                    blacklistDownload.DeviceNumber = this.DeviceNumberHex;
                    blacklistDownload.BlacklistOrder = ((short)(this.DownloadBlacklistCount + 1)).ToBytes();
                    blacklistDownload.Foot = blacklistDownload.BuildFoot();

                    this.LocalSocket.BeginSend(blacklistDownload.BuildFull());
                }
            }
        }