public void RemoveClient(GroupWebSocketService client) { lock (clients) clients.Remove(client); if (client.groups.Contains(this)) { client.groups.Remove(this); } }
public void AddClient(GroupWebSocketService client) { lock (clients) clients.Add(client); if (!client.groups.Contains(this)) { client.groups.Add(this); } }
/// <summary> /// Adds a client to a group /// </summary> /// <param name="query"></param> public WebSocketGroup AddClient(GroupWebSocketService client, WebSocketGroupQuery query) { //Get a group for this client WebSocketGroup g = GetClientGroup(query); //Add client to group g.AddClient(client); return(g); }
public void RemoveClient(GroupWebSocketService client) { while (client.groups.Count > 0) { //Get group var g = client.groups[0]; //Remove the client from the group g.RemoveClient(client); //If this group is empty, remove it if (g.GetClientCount() == 0) { RemoveGroup(g); } } }