public override void Join(Action <IChatChannel> callback, string channel) { ChannelName = "#" + channel.Replace("#", ""); SetupStatsWatcher(); if (String.IsNullOrWhiteSpace(channel)) { return; } webSocket = new WebSocketBase(); webSocket.Origin = "http://www.cybergame.tv"; webSocket.ConnectHandler = () => { }; webSocket.DisconnectHandler = () => { Log.WriteError("Cybergame.tv disconnected {0}", ChannelName); if (LeaveCallback != null) { LeaveCallback(this); } }; JoinCallback = callback; webSocket.ReceiveMessageHandler = ReadRawMessage; webSocket.Path = String.Format("/{0}/{1}/websocket", Rnd.RandomWebSocketServerNum(0x1e3), Rnd.RandomWebSocketString()); webSocket.Port = "9090"; webSocket.Host = "cybergame.tv"; webSocket.Connect(); }
private void Connect() { var servers = JsonUtil.DeserializeUrl <HitboxServer[]>("https://www.hitbox.tv/api/chat/servers?redis=true"); if (servers == null) { return; } int port = 0; if (int.TryParse(webSocket.Port, out port)) { GetRandomIP(servers.Select(s => s.server_ip).ToArray(), int.Parse(webSocket.Port), (ip) => { if (!String.IsNullOrWhiteSpace(ip)) { using (var webClient = new WebClientBase()) { string pathHash = this.With(x => webClient.Download(String.Format("http://{0}/socket.io/1/{1}", ip, Time.UnixTimestamp()))) .With(x => new String(x.TakeWhile(c => !c.Equals(':')).ToArray())); webSocket.Path = String.Format("/socket.io/1/websocket/{0}", pathHash); webSocket.Host = ip; webSocket.Connect(); } } }); } }
private void Connect() { Uri serverUri; if (!Uri.TryCreate(this.With(x => Chat.Config.GetParameterValue("ServerUri")).With(x => x.ToString()), UriKind.Absolute, out serverUri)) { webSocket.Path = String.Format("/chat/{0}/{1}/websocket", Rnd.RandomWebSocketServerNum(0x1e3), Rnd.RandomWebSocketString()); webSocket.Port = "8081"; webSocket.Host = "chat.goodgame.ru"; } else { webSocket.Path = String.Format("{0}/{1}/{2}/websocket", serverUri.AbsolutePath, Rnd.RandomWebSocketServerNum(0x1e3), Rnd.RandomWebSocketString()); webSocket.Port = serverUri.Port.ToString(); webSocket.Host = serverUri.Host; } webSocket.Connect(); }
private void Connect() { if (obsRemoteWebSocket != null && !obsRemoteWebSocket.IsClosed) { obsRemoteWebSocket.Disconnect(); obsRemoteWebSocket = null; } obsRemoteWebSocket = new WebSocketBase() { Host = Config.GetParameterValue("Host") as string, Port = "4444", SubProtocol = "obsapi", Origin = "http://client.obsremote.com", Path = String.Empty, ReceiveMessageHandler = HandleOBSRemoteMessage, }; obsRemoteWebSocket.ConnectHandler = () => { Status.IsConnected = true; Status.IsConnecting = false; if (!Login()) { Status.IsLoginFailed = true; } else { Status.IsLoggedIn = true; GetVersion(); GetAuthRequired(); Status.IsStarting = false; //GetSceneList(); //GetStreamingStatus(); //GetVolumes(); } }; obsRemoteWebSocket.DisconnectHandler = () => { Log.WriteWarning("OBS socket disconnected!"); if (!Status.IsStopping) { if (Status.IsLoginFailed) { return; } Status.ResetToDefault(); Thread.Sleep(1000); Start(); } else { Status.ResetToDefault(); } }; Status.IsConnecting = true; obsRemoteWebSocket.Connect(); }
public override void Join(Action <IChatChannel> callback, string channel) { ChannelName = "#" + channel.Replace("#", ""); SetupStatsWatcher(); JoinCallback = callback; webSocket = new WebSocketBase(); webSocket.Host = "api.gaminglive.tv"; webSocket.PingInterval = 0; webSocket.Origin = "http://www.gaminglive.tv"; webSocket.Path = String.Format("/chat/{0}?nick={1}&authToken={2}", ChannelName.Replace("#", ""), Chat.IsAnonymous ? (Chat as ChatBase).AnonymousNickName : Chat.NickName, Chat.IsAnonymous ? (Chat as ChatBase).AnonymousNickName : Chat.Config.GetParameterValue("AuthToken").ToString()); disconnectTimer = new Timer((sender) => { Log.WriteInfo("Gaminglive socket state: {0}", webSocket.State.ToString()); Log.WriteInfo("Gaminglive got no ping reply. Disconnecting"); Leave(); }, this, Timeout.Infinite, Timeout.Infinite); pingTimer = new Timer((sender) => { lock (pingLock) { Log.WriteInfo("Gaminglive ping to {0}", ChannelName); SendMessage(new ChatMessage() { Text = "!" }); disconnectTimer.Change(5000, Timeout.Infinite); } }, this, Timeout.Infinite, Timeout.Infinite); webSocket.ConnectHandler = () => { if (JoinCallback != null) { JoinCallback(this); } Chat.Status.IsLoggedIn = !Chat.IsAnonymous; Chat.Status.IsConnected = true; Chat.Status.IsStarting = false; if (!Chat.IsAnonymous) { pingTimer.Change(5000, pingInterval); } else { pingTimer.Change(300000, Timeout.Infinite); } }; webSocket.DisconnectHandler = () => { if (LeaveCallback != null) { LeaveCallback(this); } }; webSocket.ReceiveMessageHandler = ReadRawMessage; webSocket.Connect(); }
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(); }