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); } } }
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)); }
private void StopChannel(string channelId) { var channel = GetChannel(channelId); PeerCast.CloseChannel(channel); }