Esempio n. 1
0
        private void OnRecvMessage(IPEndPoint ipinfo, byte[] data)
        {
            try {
                DHTMessage msg = DHTMessage.ParseBuffer(data);
                if (msg == null)
                {
                    return;
                }

                if (msg.IsSimilarTo(fClientVer))
                {
                    fLogger.WriteDebug(">>>> Received a message from a similar client from {0}", ipinfo);
                }

                switch (msg.Type)
                {
                case MessageType.Response:
                    OnRecvResponseX(ipinfo, msg as DHTResponseMessage);
                    break;

                case MessageType.Query:
                    OnRecvQueryX(ipinfo, msg as DHTQueryMessage);
                    break;

                case MessageType.Error:
                    OnRecvErrorX(ipinfo, msg as DHTErrorMessage);
                    break;
                }
            } catch (Exception ex) {
                fLogger.WriteError("DHTClient.OnRecvMessage(): ", ex);
            }
        }
Esempio n. 2
0
        protected override void OnRecvMessage(IPEndPoint ipinfo, byte[] data)
        {
            try {
                DHTMessage msg = DHTMessage.ParseBuffer(data);
                if (msg == null)
                {
                    return;
                }

                if (msg.IsSimilarTo(fClientVer))
                {
                    // Received a message from a similar client
                    // many false positives, client version is not unique
                }

                switch (msg.Type)
                {
                case MessageType.Response:
                    OnRecvResponseX(ipinfo, msg as DHTResponseMessage);
                    break;

                case MessageType.Query:
                    OnRecvQueryX(ipinfo, msg as DHTQueryMessage);
                    break;

                case MessageType.Error:
                    OnRecvErrorX(ipinfo, msg as DHTErrorMessage);
                    break;
                }
            } catch (Exception ex) {
                fLogger.WriteError("OnRecvMessage()", ex);
            }
        }