Example #1
0
 protected void OnReceive(SubscribeMessage e)
 {
     try
     {
         Receive?.Invoke(this, e);
     }
     catch { }
 }
Example #2
0
        private void ProcessReceiveData(Result result)
        {
            var items = result.Data;

            for (int i = 0; i < items.Count; i = i + 3)
            {
                SubscribeMessage subscribeMessage = new SubscribeMessage();
                if ((string)items[i].Data == "subscribe")
                {
                    subscribeMessage.Type = SubscribeMessageType.Subscribe;
                }
                else
                {
                    subscribeMessage.Type = SubscribeMessageType.Message;
                }
                subscribeMessage.Channel = (string)items[i + 1].Data;
                subscribeMessage.Data    = items[i + 2].Data;
                if (subscribeMessage.Type == SubscribeMessageType.Message)
                {
                    if (mChannels.TryGetValue(subscribeMessage.Channel, out ChannelRegister register))
                    {
                        try
                        {
                            register.Action.DynamicInvoke(subscribeMessage.Data);
                        }
                        catch (Exception e_)
                        {
                            subscribeMessage.Type = SubscribeMessageType.Error;
                            subscribeMessage.Data = $"invoke {subscribeMessage.Channel} error {e_.Message}";
                            OnReceive(subscribeMessage);
                        }
                    }
                    else
                    {
                        OnReceive(subscribeMessage);
                    }
                }
                else
                {
                    OnReceive(subscribeMessage);
                }
            }
        }
Example #3
0
        private void ProcessReceiveData(Result result)
        {
            var items = result.Data;

            for (int i = 0; i < items.Count; i = i + 3)
            {
                SubscribeMessage subscribeMessage = new SubscribeMessage();
                if ((string)items[i].Data == "subscribe")
                {
                    subscribeMessage.Type = SubscribeMessageType.Subscribe;
                }
                else
                {
                    subscribeMessage.Type = SubscribeMessageType.Message;
                }
                subscribeMessage.Channel = (string)items[i + 1].Data;
                subscribeMessage.Data    = items[i + 2].Data;
                OnReceive(subscribeMessage);
            }
        }