Exemplo n.º 1
0
        override protected void HandleReceivedMessage(Message message)
        {
            base.HandleReceivedMessage(message);

            Message response = null;

            switch (message.Type)
            {
            case MessageType.TRACE:
                _tracing2Client = true;
                HandleMessage?.Invoke(this, message);
                break;

            case MessageType.PING:
                response = CreatePingResponse(message);
                SendMessage(response);
                break;

            case MessageType.STATUS_REQUEST:
                response = CreateStatusResponse(message);
                SendMessage(response);
                break;

            case MessageType.SUBSCRIBE:
                if (message.HasValue("Subscriber"))
                {
                    try
                    {
                        AddSubscriber(ConnectionManager.Subscriber.Parse(message.GetString("Subscriber")));
                    }
                    catch (Exception e)
                    {
                        Tracing?.TraceEvent(TraceEventType.Error, 2000, e.Message);
                    }
                }
                break;

            case MessageType.UNSUBSCRIBE:
                if (message.HasValue("Subscriber"))
                {
                    RemoveSubscriber(message.GetString("Subscriber"));
                }
                break;

            default:
                int priorSize = ThreadExecutionManager.MaxQueueSize;
                ThreadExecutionManager.MaxQueueSize = 256;
                ThreadExecutionManager.Execute <Message>("HandleMessage-" + ID, HandleMessageDelegateWrapper, message);
                ThreadExecutionManager.MaxQueueSize = priorSize;
                break;
            }
        }
Exemplo n.º 2
0
        override public void ParseMessage(Message message)
        {
            int       port = message.GetInt("Port");
            IPAddress ip   = IPAddress.Parse(message.GetString("IP"));

            IP   = ip;
            Port = port;
        }