private void Fill(List<string> data, Client c) { data.Clear(); data.Add(c.Src_ID.ToString()); data.Add(c.Firewall_IP.ToString()); data.Add(c.ComputerName.ToString()); data.Add(c.UserName); }
void RemoveViewer(Client c) { if(c == null) return; lock(ClientsLock) {//ensure the Remove Function doesnt interleave here!! if(c.Status == Client.Connection_Status.Paired && c.Dst_ID > -1 && c.Dst_ID < Constants.MAXCLIENTS) {//if the connection is paired and there is a valid server var server = _Clients[c.Dst_ID]; if(server != null) { server.ClientObject.ConnectTime = DateTime.Now; server.ClientObject.Status = Client.Connection_Status.Reserved;//servers go into a reserved state so they can reconnect and use the same slot server.ClientObject.Dst_ID = -1;//reset its dst id } } c.Status = Client.Connection_Status.Disconnected; Ids.Enqueue(c.Src_ID);//add the id in _Clients[c.Src_ID] = null;//clear the slot c.Src_ID = c.Dst_ID = -1; } if(OnClientDisconnectEvent != null) OnClientDisconnectEvent(new List<Client> { c }); }
void RemoveServer(Client c) { if(c == null) return; lock(ClientsLock) {//ensure the Remove Function doesnt interleave here!! if(c.Status == Client.Connection_Status.Paired && c.Dst_ID > -1 && c.Dst_ID < Constants.MAXCLIENTS) {//if the connection is paired and there is a valid server var viewer = _Clients[c.Dst_ID]; if(viewer != null) { viewer.ClientObject.Status = Client.Connection_Status.Disconnected; viewer.SocketObject.ShouldDisconnect = true;//set this to disconnect the viewer _Clients[c.Dst_ID] = null;//clear the viewer slot Ids.Enqueue(c.Dst_ID);//add the id in the id } } c.ConnectTime = DateTime.Now;//this is now used as a timeout value c.Status = Client.Connection_Status.Reserved;//servers go into a reserved state so they can reconnect and use the same slot c.Dst_ID = -1;//reset the dst id as well } if(OnClientDisconnectEvent != null) OnClientDisconnectEvent(new List<Client> { c }); }
public void Remove(Client c) { if(c.Host == Client.Host_Type.Viewer) RemoveViewer(c); else if(c.Host == Client.Host_Type.Server) RemoveServer(c); else Debug.Assert(false);//this should never be hit!! }