예제 #1
0
        protected override void OnMessage(MessageEventArgs e)
        {
            base.OnMessage(e);

            #pragma warning disable 618

            // e.Is* does not seem to work as of 12/30/15

            if (e.Type == Opcode.Binary)
            {
                _server.OnTrace(XenLogLevel.Warn, @"Binary messages are unsupported. Ignored.");
                return;
            }


            if (e.Type == Opcode.Ping || e.Type == Opcode.Pong)
            {
                _server.OnTrace(XenLogLevel.Trace, @"Ping/Pong received from toolbox.");
                return;
            }


            if (e.Type == Opcode.Text)
            {
                // The data property contains the text message received from the toolbox.
                // It's not known if the data is valid JSON.

                var msgEvent = new SocketMessageReceivedEventArgs
                {
                    Message = e.Data
                };

                _server.OnMessage(msgEvent);
            }

            #pragma warning restore 618
        }
예제 #2
0
 protected virtual void OnMessageReceived(SocketMessageReceivedEventArgs e)
 {
     MessageReceived?.Invoke(this, e);
 }
예제 #3
0
 internal virtual void OnMessage(SocketMessageReceivedEventArgs e)
 {
     Message?.Invoke(this, e);
 }