public virtual void onMessage(string message)
 {
     sessionThread.queue(new Task(() =>
     {
         listener.onMessage(message);
     }));
 }
Exemplo n.º 2
0
            /*
             * Note 1
             * Methods below are called by WebSocketProvider internal threads.
             * Their bodies must be delegated to SessionThread.
             *
             * Note 2
             * It can happen that the socket is disconnected but the listeners, notified by Netty,
             * still receive events (for example when the socket is closed because the control link has changed).
             * These events must be ignored.
             */

            public virtual void onOpen()
            {
                sessionThread.queue(new Task(() =>
                {
                    if (state.Equals(InternalState.DISCONNECTED))
                    {
                        log.Warn("onOpen event discarded");
                        return;
                    }
                    state = InternalState.CONNECTED;
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("WebSocket transport onOpen: " + state);
                    }
                    connectionListener.onOpen();
                }));
            }