Exemple #1
0
        /// <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 virtual void RemoveClient(IStudioComponent client)
 {
     if (_clients.Remove(client))
     {
         ClientRemoved?.Invoke(this, client);
     }
 }
        public static void RemoveClient(NetworkClient target, ClientRemoveReason reason)
        {
            target.Dispose();
            _Clients.Remove(target);

            ClientRemoved?.Invoke(target, reason);
        }
Exemple #4
0
 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);
 }
Exemple #5
0
        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);
                });
            }
        }
 public void RemoveListener(RoomObserverBase observer)
 {
     if (Clients.Contains(observer))
     {
         Clients.Remove(observer);
         ClientRemoved?.Invoke(Name, observer.client.Username);
     }
 }
Exemple #7
0
        /// <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;
         }
     }
 }
Exemple #9
0
        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);
            }
        }
Exemple #10
0
        /// <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
                    });
                }
            }
        }
Exemple #13
0
        private void RemoveClient(CClient client)
        {
            RunOnUiThread(delegate
            {
                client.State = ClientState.Refused;
            });

            lock (Clients)
            {
                Clients.Remove(client);
            }

            RunOnUiThread(delegate
            {
                ClientRemoved?.Invoke(client);

                ClientsChanged?.Invoke(Clients);
            });
        }
Exemple #14
0
 private ClientMachine ClientMachineFromEvent(ClientRemoved @event) => @event.ClientMachine;
 private void OnClientRemoved(string obj)
 => ClientRemoved?.Invoke(obj);
Exemple #16
0
 public void RemoveClient(ActiveCommandInfo activeCommandInfo, Client client)
 {
     ClientRemoved?.Invoke(this, new ActiveCommandClientEventArgs(activeCommandInfo, client));
 }
Exemple #17
0
 public void When(ClientRemoved clientRemoved)
 {
     Deleted = clientRemoved.Deleted;
 }
 public void Handle(ClientRemoved e)
 {
     _clients.Remove(_clients.Single(c => c.Id == e.ClientMachine.Id));
 }
Exemple #19
0
 private void Apply(ClientRemoved _)
 {
     _name           = null;
     _normalizedName = null;
     ClearConcurrencyCheckStamp();
 }
 public Task Handle(ClientRemoved notification, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }