public static void RemoveClient(NetworkClient target, ClientRemoveReason reason) { target.Dispose(); _Clients.Remove(target); ClientRemoved?.Invoke(target, reason); }
private void CleanupClients() { var currentUnixTimestamp = BaseModel.GetCurrentUnixTimestamp(); var hasChange = false; lock (Clients) { foreach (var client in Clients.ToList()) { if (currentUnixTimestamp - client.RefreshTime > CConstant.ClientCleanupPeriod / 1000) { Clients.Remove(client); RunOnUiThread(delegate { ClientRemoved?.Invoke(client); }); hasChange = true; } } } if (hasChange) { RunOnUiThread(delegate { ClientsChanged?.Invoke(Clients); }); } }
/// <summary> /// Checks registered clients and removes old clients from list /// </summary> void OldClientCheck(object sender, ElapsedEventArgs e) { if (Clients == null) { return; } lock (Clients) { // do a sweep of old clients var now = DateTime.Now; for (int i = 0; i < Clients.Count; i++) { var c = Clients[i]; if (c.Online) { continue; } // remove inactive clients older than 1 day if (now.Subtract(c.LastConnected).TotalMinutes > config.MaxClientAgeMinutes) { Clients.RemoveAt(i); ClientRemoved?.Invoke(c, null); i--; } } } }
public static void RemoveClient(ClientContainer clientContainer) { System.Console.WriteLine("removing client"); AllClients.Remove(clientContainer.Id); if (UsingRoomHandling) { var p = clientContainer.StoredData["Room"] as string; if (Rooms.ContainsKey(p)) { Rooms[p].RoomClients.Remove(clientContainer.Id); foreach (var item in Rooms[p].RoomClients.Values) { Server.MessagesToSend.Enqueue(new SendableMessage { Address = item.Id, Message = new PlayerRemovedMessage { ApplicationVersion = Server.ApplicationVersion, DetourVersion = DetourVersion, MessageType = 5, Id = clientContainer.Id, RoomId = p } }); } } } ClientRemoved?.Invoke(clientContainer.Id); }
public virtual void RemoveClient(IStudioComponent client) { if (_clients.Remove(client)) { ClientRemoved?.Invoke(this, client); } }
public void RemoveListener(RoomObserverBase observer) { if (Clients.Contains(observer)) { Clients.Remove(observer); ClientRemoved?.Invoke(Name, observer.client.Username); } }
/// <summary> /// Удалить клиента по идентификатору /// </summary> /// <param name="clientKey">Идентификатор клиента</param> public void RemoveClient(int clientKey) { _clients.Remove(clientKey); ClientRemoved?.Invoke(clientKey, EventArgs.Empty); var rentedCarsForClient = RentedCars.Where(s => s.Client.ClientId == clientKey).ToList(); for (int i = 0; i < rentedCarsForClient.Count; i++) { RemoveRentedCar(rentedCarsForClient[i]); } }
public void RemoveListener(string observer) { foreach (RoomObserverBase ro in Clients) { if (ro.client.Username == observer) { Clients.Remove(ro); ClientRemoved?.Invoke(Name, ro.client.Username); break; } } }
public void RemoveClient(IRailNetPeer netClient) { if (clients.ContainsKey(netClient)) { RailServerPeer client = clients[netClient]; clients.Remove(netClient); Room.RemoveClient(client); // Revoke control of all the entities controlled by that client client.Shutdown(); ClientRemoved?.Invoke(client); } }
/// <summary> /// Удалить клиента по идентификатору /// </summary> /// <param name="clientKey">Идентификатор клиента</param> public void RemoveClient(int clientKey) { _clients.Remove(clientKey); //Генерируем событие о том, что клиент удалён ClientRemoved?.Invoke(clientKey, EventArgs.Empty); //Получаем список сведений о поселении клиента var settlementsForClient = Settlements.Where(s => s.Client.ClientId == clientKey).ToList(); for (int i = 0; i < settlementsForClient.Count; i++) { //Удаляем сведения о поселении клиента RemoveSettlement(settlementsForClient[i]); } }
private void ReverseProxyClientOnDisconnected(object sender, EventArgs eventArgs) { var reverseProxyClient = (ReverseProxyClient)sender; ConnectionInfo.UnsafeSendCommand(this, 5, writer => { writer.Write((byte)ReverseProxyCommunication.Disconnect); writer.Write(reverseProxyClient.ConnectionId); }); lock (_clientsLock) _clients.Remove(reverseProxyClient); ClientRemoved?.Invoke(this, reverseProxyClient); }
private void RemoveClient(TcpClient client) { lock (m_Clients) { if (m_Clients.Contains(client)) { m_Clients.Remove(client); m_ReadonlyClients = m_Clients.ToArray(); ClientRemoved?.Invoke( this, new TcpClientEventArgs { Client = client }); } } }
private void RemoveClient(CClient client) { RunOnUiThread(delegate { client.State = ClientState.Refused; }); lock (Clients) { Clients.Remove(client); } RunOnUiThread(delegate { ClientRemoved?.Invoke(client); ClientsChanged?.Invoke(Clients); }); }
private void OnClientRemoved(string obj) => ClientRemoved?.Invoke(obj);
public void RemoveClient(ActiveCommandInfo activeCommandInfo, Client client) { ClientRemoved?.Invoke(this, new ActiveCommandClientEventArgs(activeCommandInfo, client)); }