Example #1
0
        private void WebsocketOnMessage(IWebsocket ws, string data)
        {
            if (ws != websocket)
            {
                return;
            }

            try
            {
                var msg = MessageSerialization.Deserialize(data);
                Log(LogLevel.Trace, "socket", string.Format("received: {0}", msg));

                if (channels.ContainsKey(msg.topic))
                {
                    channels[msg.topic].Trigger(msg);
                }

                OnMessage?.Invoke(data);
            }
            catch (Exception e)
            {
                UnityEngine.MonoBehaviour.print("CATCHED EXCEPTION!");
                UnityEngine.MonoBehaviour.print(e);
            }
        }
Example #2
0
        private void WebsocketOnMessage(IWebsocket ws, string data)
        {
            if (ws != websocket)
            {
                return;
            }

            var msg = MessageSerialization.Deserialize(data);

            Log(LogLevel.Trace, "socket", string.Format("received: {0}", msg.ToString()));

            if (channels.ContainsKey(msg.topic))
            {
                channels[msg.topic].Trigger(msg);
            }

            if (OnMessage != null)
            {
                OnMessage(data);
            }
        }
Example #3
0
        private void WebsocketOnMessage(IWebsocket ws, string data)
        {
            if (ws != websocket)
            {
                return;
            }
            var msg = MessageSerialization.Deserialize(data);

            Log(LogLevel.Trace, "socket", string.Format("received: {0}", msg.ToString()));

            if (msg.@ref != null && msg.@ref == pendingHeartbeatRef)
            {
                ResetHeartbeat();
            }

            if (channels.ContainsKey(msg.topic))
            {
                channels[msg.topic].Trigger(msg);
            }

            OnMessage?.Invoke(data);
        }