Ejemplo n.º 1
0
        private void SendCredentials()
        {
            var token      = Chat.Config.GetParameterValue("AuthToken").ToString();
            var authPacket = new CybergamePacket()
            {
                Command = "login",
                Message = new CybergameData()
                {
                    Login    = Chat.NickName ?? "",
                    Password = token ?? "",
                    Channel  = ChannelName,
                },
            };

            Log.WriteInfo("Cybergame sending {0}", authPacket.ToString());
            webSocket.Send(authPacket.ToString());
        }
Ejemplo n.º 2
0
        public override void SendMessage(ChatMessage message)
        {
            if (Chat.IsAnonymous)
            {
                return;
            }

            dynamic jsonMessage = new { message = message.Text, color = "orange" };

            webSocket.Send(JsonConvert.SerializeObject(jsonMessage));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        private void SendChannelJoin()
        {
            var channelId = (Chat as GoodgameChat).GetChannelId(ChannelName);
            //Log.WriteInfo("Goodgame serializing join packet. ChannelId: {0}", channelId);
            var joinPacket = new GoodgamePacket()
            {
                Type = "join",
                Data = new GoodGameData()
                {
                    ChannelId = channelId,
                    IsHidden  = false,
                    Mobile    = 0,
                },
            };

            if (joinPacket != null && joinPacket.Data != null)
            {
                //Log.WriteInfo("Goodgame sending {0}", joinPacket.ToString());
                webSocket.Send(joinPacket.ToString());
            }
        }
Ejemplo n.º 5
0
        public override void SendMessage(ChatMessage message)
        {
            if (Chat.IsAnonymous || String.IsNullOrWhiteSpace(message.Channel) ||
                String.IsNullOrWhiteSpace(message.FromUserName) ||
                String.IsNullOrWhiteSpace(message.Text))
            {
                return;
            }

            if (webSocket == null)
            {
                return;
            }

            webSocket.Send(String.Format(
                               @"42[""send"",{{""room"":""{0}"",""msg"":""{1}"",""token"":""{2}""}}]",
                               ChannelName.Replace("#", ""),
                               message.Text,
                               channelToken
                               ));

            //Send message
        }
Ejemplo n.º 6
0
 private void Send(string message)
 {
     Log.WriteInfo("OBSRemote service is sending a message:{0}", message);
     obsRemoteWebSocket.Send(message);
 }
Ejemplo n.º 7
0
        public override void Join(Action <IChatChannel> callback, string channel)
        {
            ChannelName = "#" + channel.Replace("#", "");

            if (ChannelName.Contains("@"))
            {
                return;
            }

            string sid = String.Empty;

            using (WebClientBase webClient = new WebClientBase())
            {
                webClient.Cookies = (Chat as ConnectcastChat).LoginWebClient.Cookies;
                channelToken      = this.With(x => webClient.Download(String.Format("http://connectcast.tv/chat/{0}", ChannelName.Replace("#", ""))))
                                    .With(x => Re.GetSubString(x, "token[^']*'(.*?)'"));

                sid = this.With(x => webClient.Download(
                                    String.Format("https://chat.connectcast.tv:3000/socket.io/?EIO=3&transport=polling&t=", Time.UnixTimestamp())))
                      .With(x => Re.GetSubString(x, @"""sid"":""(.*?)"""));

                if (String.IsNullOrWhiteSpace(channelToken) ||
                    channelToken.Equals("NOTOKEN", StringComparison.InvariantCultureIgnoreCase))
                {
                    channelToken = "NOTOKEN";
                }
                else
                {
                    Chat.Status.IsLoggedIn = true;
                }
            }

            if (String.IsNullOrWhiteSpace(sid) && LeaveCallback != null)
            {
                LeaveCallback(this);
                return;
            }


            webSocket = new WebSocketBase();
            webSocket.PingInterval = 0;

            JoinCallback = callback;

            webSocket.DisconnectHandler = () =>
            {
                if (pingTimer != null)
                {
                    pingTimer.Change(Timeout.Infinite, Timeout.Infinite);
                }

                Leave();
            };

            webSocket.ReceiveMessageHandler = ReadRawMessage;

            webSocket.Path     = String.Format("/socket.io/?EIO=3&transport=websocket&sid={0}", sid);
            webSocket.Port     = "3000";
            webSocket.IsSecure = true;
            webSocket.Origin   = "http://connectcast.tv";
            webSocket.Cookies  = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("io", sid)
            };
            webSocket.Host           = "chat.connectcast.tv";
            webSocket.ConnectHandler = () =>
            {
                if (pingTimer != null)
                {
                    pingTimer.Change(PING_INTERVAL, PING_INTERVAL);
                }

                if (disconnectTimer != null)
                {
                    disconnectTimer.Change(PING_INTERVAL * 2, Timeout.Infinite);
                }

                webSocket.Send("2probe");
            };
            SetupStatsWatcher();
            webSocket.Connect();
        }