예제 #1
0
        public override void Leave()
        {
            Log.WriteInfo("Gaminglive leaving {0}", ChannelName);

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

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

            if (statsPoller != null)
            {
                statsPoller.Stop();
            }

            if (webSocket != null && !webSocket.IsClosed)
            {
                webSocket.Disconnect();
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        private void PollFollowers()
        {
            if (followerPoller != null)
            {
                followerPoller.Stop();
            }

            if (IsAnonymous)
            {
                return;
            }

            followerPoller.Id       = "followersPoller";
            followerPoller.Interval = 10000;
            followerPoller.Uri      = new Uri(String.Format(@"http://api.twitch.tv/kraken/channels/{0}/follows?limit=50&offset=0&on_site=1",
                                                            NickName));

            followerPoller.ReadStream = (stream) =>
            {
                if (stream == null)
                {
                    return;
                }

                using (stream)
                {
                    var followers = JsonUtil.DeserializeStream <TwitchFollowers>(stream);
                    if (followers != null && followers.follows != null)
                    {
                        if (currentFollowers.follows == null)
                        {
                            currentFollowers.follows = followers.follows.ToList();
                        }
                        else if (followers.follows.Count > 0)
                        {
                            var newFollowers = followers.follows.Take(25).Except(currentFollowers.follows, new LambdaComparer <TwitchFollow>((x, y) => x.user.display_name.Equals(y.user.display_name)));
                            foreach (var follower in newFollowers)
                            {
                                Log.WriteInfo("New Twitch follower: {0}", follower.user.display_name);
                                if (AddFollower != null)
                                {
                                    AddFollower(new ChatUser()
                                    {
                                        NickName = follower.user.display_name,
                                        ChatName = ChatName
                                    });
                                }
                            }

                            currentFollowers.follows = followers.follows.ToList();
                        }
                    }
                }
            };
            followerPoller.Start();
        }
예제 #4
0
        public override void Leave()
        {
            Log.WriteInfo("Youtubechannel leaving {0}", ChannelName);

            if (checkTimer != null)
            {
                checkTimer.Change(Timeout.Infinite, Timeout.Infinite);
            }
            if (chatPoller != null)
            {
                chatPoller.Stop();
            }
            if (statsPoller != null)
            {
                statsPoller.Stop();
            }

            if (LeaveCallback != null)
            {
                LeaveCallback(this);
            }
        }
예제 #5
0
        public override void Leave()
        {
            Log.WriteInfo("Hitbox leaving {0}", ChannelName);
            if (webSocket != null && !webSocket.IsClosed)
            {
                webSocket.Disconnect();
            }

            if (timerEveryMinute != null)
            {
                timerEveryMinute.Change(Timeout.Infinite, Timeout.Infinite);
            }

            if (statsPoller != null)
            {
                statsPoller.Stop();
            }
        }
예제 #6
0
        public override void Leave()
        {
            if (ircClient != null)
            {
                TryIrc(() => {
                    ircClient.Disconnected       -= ircClient_Disconnected;
                    ircClient.RawMessageReceived -= ircClient_RawMessageReceived;
                });
            }

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

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

            if (statsPoller != null)
            {
                statsPoller.Stop();
            }

            Log.WriteInfo("Twitch leaving {0}", ChannelName);

            TryIrc(() => ircClient.Quit("bye!"));
            TryIrc(() => ircClient.Dispose());

            ircClient = null;

            if (LeaveCallback != null)
            {
                LeaveCallback(this);
            }
        }
예제 #7
0
        private void PollNotifications()
        {
            if (notificationPoller != null)
            {
                notificationPoller.Stop();
            }

            if (!Status.IsLoggedIn)
            {
                return;
            }

            notificationPoller = new WebPoller()
            {
                Id       = "followersPoller",
                Interval = 5000,
                Uri      = new Uri(@"https://api.gaminglive.tv/notifications"),
            };
            notificationPoller.Headers["Auth-Token"] = Config.GetParameterValue("AuthToken") as string;

            notificationPoller.ReadStream = (stream) =>
            {
                if (stream == null)
                {
                    return;
                }

                using (stream)
                {
                    var notifications = JsonUtil.DeserializeStream <GamingLiveNotification[]>(stream);

                    long lastFollow = 0;
                    long.TryParse(Config.GetParameterValue("LastFollowerTime") as string, out lastFollow);

                    foreach (var notification in notifications)
                    {
                        if (notification.t.Equals("user:followed", StringComparison.InvariantCultureIgnoreCase))
                        {
                            if (notification.at > lastFollow)
                            {
                                if (currentFollowers.Any(n => n.from == notification.from))
                                {
                                    continue;
                                }

                                currentFollowers.Add(notification);
                                Config.SetParameterValue("LastFollowerTime", notification.at.ToString());
                                if (AddFollower != null)
                                {
                                    AddFollower(new ChatUser()
                                    {
                                        NickName = notification.from,
                                        ChatName = ChatName
                                    });
                                }
                            }
                        }
                    }
                }
            };

            notificationPoller.Start();
        }
예제 #8
0
        private void PollFollowers()
        {
            if (followerPoller != null)
            {
                followerPoller.Stop();
            }

            if (!Status.IsLoggedIn)
            {
                return;
            }

            var getUrl   = @"https://www.hitbox.tv/api/followers/user/{0}?limit=50";
            var userName = Config.GetParameterValue("Username") as string;

            if (userName.Equals(AnonymousNickName, StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            followerPoller.Id         = "followersPoller";
            followerPoller.Interval   = 10000;
            followerPoller.Uri        = new Uri(String.Format(getUrl, HttpUtility.UrlEncode(userName.ToLower())));
            followerPoller.ReadStream = (stream) =>
            {
                if (stream == null)
                {
                    return;
                }

                using ( stream )
                {
                    var followers = JsonUtil.DeserializeStream <HitboxFollowers>(stream);
                    if (followers != null && followers.followers != null)
                    {
                        if (currentFollowers.followers == null)
                        {
                            currentFollowers.followers = followers.followers.ToList();
                        }
                        else if (followers.followers.Count > 0)
                        {
                            var newFollowers = followers.followers.Take(25).Except(currentFollowers.followers, new LambdaComparer <HitboxFollower>((x, y) => x.user_name.Equals(y.user_name)));
                            foreach (var follower in newFollowers)
                            {
                                if (AddFollower != null)
                                {
                                    AddFollower(new ChatUser()
                                    {
                                        NickName = follower.user_name,
                                        ChatName = ChatName
                                    });
                                }
                            }

                            currentFollowers.followers = followers.followers.ToList();
                        }
                    }
                }
            };
            followerPoller.Start();
        }