public void Close(ushort client_id) { allocated_client_id.Remove(client_id); allocated_stream_id.Remove(client_id); StreamConnectState state; connects.TryGetValue(client_id, out state); IStreamConnect connect = state.Connect; prepare_to_remove.Add(client_id); if (connect.IsPublishing) { UnRegisterPublish(client_id); } if (connect.IsPlaying) { var client_channels = routedClients.FindAll((t) => (t.Item1 == client_id || t.Item2 == client_id)); routedClients.RemoveAll((t) => (t.Item1 == client_id)); foreach (var i in client_channels) { routedClients.Remove(i); } } connect.OnDisconnected(new ExceptionalEventArgs("disconnected")); }
void DisconnectSession(ushort client_id) { ClientSession clientSession; if (ClientSessions.TryGetValue(client_id, out clientSession)) { if (clientSession != null) { IStreamConnect client = clientSession.Connect; if (client.IsPublishing) { UnRegisterPublish(client_id); } if (client.IsPlaying) { var client_channels = _routedClients.FindAll((t) => (t.Item1 == client_id || t.Item2 == client_id)); _routedClients.RemoveAll((t) => (t.Item1 == client_id)); foreach (var i in client_channels) { _routedClients.Remove(i); } } client.OnDisconnected(new ExceptionalEventArgs("disconnected")); } } ClientSessions.Remove(client_id); }