Ejemplo n.º 1
0
        /// <summary>
        /// Processes the received text packet.
        /// </summary>
        /// <param name="packetMessage">The receive text packet</param>
        /// <returns>An awaitable task</returns>
        protected override Task ProcessReceivedPacket(string packetMessage)
        {
            if (!string.IsNullOrEmpty(packetMessage))
            {
                ClientResponsePacketModel packet = new ClientResponsePacketModel(packetMessage);

                if (packet.IsReplyEvent)
                {
                    if (this.replyIDListeners.ContainsKey(packet.NormalRef))
                    {
                        this.replyIDListeners[packet.NormalRef] = packet;
                    }
                }

                if (this.chatSubscriptions.Contains(packet.Topic))
                {
                    ChatMessagePacketModel message = new ChatMessagePacketModel(packetMessage);
                    this.OnChatMessageReceived?.Invoke(this, message);
                }
                else if (this.channelSubscriptions.Contains(packet.Topic))
                {
                    ChannelUpdatePacketModel channelUpdate = new ChannelUpdatePacketModel(packetMessage);
                    this.OnChannelUpdated?.Invoke(this, channelUpdate);
                }
                else if (this.followSubscriptions.Contains(packet.Topic))
                {
                    FollowPacketModel follow = new FollowPacketModel(packetMessage);
                    this.OnFollowOccurred?.Invoke(this, follow);
                }
            }
            return(Task.FromResult(0));
        }
Ejemplo n.º 2
0
 private static void Client_OnChannelUpdated(object sender, ChannelUpdatePacketModel channelUpdate)
 {
     System.Console.WriteLine(string.Format("Stream Title: {0}", channelUpdate.Channel.title));
 }