Exemplo n.º 1
0
        public override void SendMessage(ChatMessage message)
        {
            if (Chat.IsAnonymous || String.IsNullOrWhiteSpace(message.Channel) ||
                String.IsNullOrWhiteSpace(message.FromUserName) ||
                String.IsNullOrWhiteSpace(message.Text))
            {
                return;
            }

            HitboxWebSocketPacket jsonMessage = new HitboxWebSocketPacket()
            {
                name = "message",
                args = new List <HitboxArg>()
                {
                    new HitboxArg()
                    {
                        method  = "chatMsg",
                        @params = new {
                            channel   = message.Channel.Replace("#", ""),
                            name      = message.FromUserName,
                            nameColor = "B404AE",
                            text      = message.Text,
                        }
                    }
                }
            };

            webSocket.Send("5:::" + JsonConvert.SerializeObject(jsonMessage));
        }
Exemplo n.º 2
0
        private void SendUserListRequest(string channel)
        {
            var hitboxPacket = new HitboxWebSocketPacket()
            {
                name = "message",
                args = new List <HitboxArg>()
                {
                    new HitboxArg()
                    {
                        method  = "getChannelUserList",
                        @params = new {
                            channel = channel.Replace("#", ""),
                        }
                    }
                }
            };
            var jsonString = JsonConvert.SerializeObject(hitboxPacket);

            webSocket.Send("5:::" + jsonString);
        }
Exemplo n.º 3
0
        private void SendCredentials(string nickname, string channel, string authToken)
        {
            var loginData = new HitboxWebSocketPacket()
            {
                name = "message",
                args = new List <HitboxArg>()
                {
                    new HitboxArg()
                    {
                        method  = "joinChannel",
                        @params = new {
                            channel = channel.Replace("#", ""),
                            name    = Chat.NickName,
                            token   = Chat.IsAnonymous ? "" : authToken ?? "",
                            isAdmin = !Chat.IsAnonymous && channel.Replace("#", "").Equals(nickname, StringComparison.InvariantCultureIgnoreCase) ? true :false,
                        }
                    }
                }
            };
            var jsonString = JsonConvert.SerializeObject(loginData);

            webSocket.Send("5:::" + jsonString);
        }