public override void Leave() { //Disconnect channel if (pingTimer != null) { pingTimer.Change(Timeout.Infinite, Timeout.Infinite); } if (disconnectTimer != null) { disconnectTimer.Change(Timeout.Infinite, Timeout.Infinite); } pingTimer = null; disconnectTimer = null; if (webSocket != null) { webSocket.Disconnect(); } if (statsPoller != null) { statsPoller.Stop(); } webSocket = null; if (LeaveCallback != null) { LeaveCallback(this); } }
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(); }
public override void Join(Action <IChatChannel> callback, string channel) { if (String.IsNullOrWhiteSpace(channel)) { return; } var authToken = Chat.Config.GetParameterValue("AuthToken") as string; ChannelName = "#" + channel.Replace("#", ""); webSocket = new WebSocketBase(); webSocket.PingInterval = 0; webSocket.Origin = "http://www.hitbox.tv"; webSocket.ConnectHandler = () => { SendCredentials(Chat.NickName, channel, authToken); if (callback != null) { callback(this); } }; webSocket.DisconnectHandler = () => { Log.WriteError("Hitbox disconnected {0}", ChannelName); if (LeaveCallback != null) { LeaveCallback(this); } }; webSocket.ReceiveMessageHandler = ReadRawMessage; Connect(); SetupStatsWatcher(); }
public override void Join(Action <IChatChannel> callback, string channel) { Thread.Sleep(random.Next(200, 500)); if (String.IsNullOrWhiteSpace(channel)) { return; } ChannelName = "#" + channel.Replace("#", ""); webSocket = new WebSocketBase(); webSocket.PingInterval = 0; webSocket.Origin = "http://goodgame.ru"; JoinCallback = callback; webSocket.DisconnectHandler = () => { timer.Change(Timeout.Infinite, Timeout.Infinite); if (LeaveCallback != null) { LeaveCallback(this); } }; webSocket.ReceiveMessageHandler = ReadRawMessage; 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(); }