Ejemplo n.º 1
0
        private void CleanupChannels(Func <Channel, bool> predicate)
        {
            if (inactiveLimit < 1)
            {
                return;
            }
            var channels = peerCast.Channels;

            foreach (var channel in channels)
            {
                if (channel.IsBroadcasting)
                {
                    continue;
                }
                if (predicate(channel))
                {
                    int time;
                    if (inactiveChannels.TryGetValue(channel, out time))
                    {
                        if (Environment.TickCount - time > inactiveLimit)
                        {
                            peerCast.CloseChannel(channel);
                            inactiveChannels.Remove(channel);
                        }
                    }
                    else
                    {
                        inactiveChannels.Add(channel, Environment.TickCount);
                    }
                }
                else
                {
                    inactiveChannels.Remove(channel);
                }
            }
            foreach (var channel in inactiveChannels.Keys.ToArray())
            {
                if (!channels.Contains(channel))
                {
                    inactiveChannels.Remove(channel);
                }
            }
        }
Ejemplo n.º 2
0
            private void OnStop(Dictionary <string, string> query)
            {
                HttpStatusCode status;
                var            parameters = new Dictionary <string, string> {
                };
                string res;
                var    channel = FindChannelFromQuery(query);

                if (channel != null)
                {
                    PeerCast.CloseChannel(channel);
                    status = HttpStatusCode.OK;
                    res    = "OK";
                }
                else
                {
                    status = HttpStatusCode.NotFound;
                    res    = "Channel NotFound";
                }
                Send(HTTPUtils.CreateResponse(status, parameters, res));
            }
Ejemplo n.º 3
0
            private void StopChannel(string channelId)
            {
                var channel = GetChannel(channelId);

                PeerCast.CloseChannel(channel);
            }