Esempio n. 1
0
        private void ClientDisconnect(DisconnectionContext ctx, ConnectionInfo inf)
        {
            lock (LockObject)
            {
                for (int i = 0; i < ClientCount; i++)
                {
                    if (!Clients[i].connectionInfo.Equals(inf))
                    {
                        continue;
                    }
                    if (Clients[i].DisconnectionMode.type == DisconnectionContext.DisconnectionType.REMOVE)
                    {
                        Clients.RemoveAt(i);
                        i--;
                    }
                    else if ((int)Clients[i].DisconnectionMode.type == 2 && GlobalDefaults.ForcibleDisconnectMode == 0)
                    {
                        Clients.RemoveAt(i);
                        i--;
                    }
                }

                OnClientDisconnect?.Invoke(ctx, inf);
            }
            if (RestartAutomatically && !Running && ClientCount < MaxClients)
            {
                StartServer();
            }
        }
Esempio n. 2
0
        public void Disconnect(DisconnectionContext ctx)
        {
            try
            {
                SendObject(ctx);
            }
            catch
            {
            }

            DisconnectionMode = ctx;
            IsConnected       = false;

            if (ctx.type == DisconnectionContext.DisconnectionType.REMOVE)
            {
                lock (LockObject)
                    ObjectQueue.Clear();
            }
        }
Esempio n. 3
0
 public void DisconnectClient(ushort index, DisconnectionContext ctx, bool remove = false)
 {
     Clients[index].Disconnect(ctx);
     if (remove)
     {
         while (GlobalDefaults.UseEncryption && !Clients[index].RecivedKey)
         {
             ;
         }
         lock (LockObject)
         {
             Clients.RemoveAt(index);
             if (RestartAutomatically && !Running && ClientCount < MaxClients)
             {
                 StartServer();
             }
         }
     }
 }
Esempio n. 4
0
 public void DisconnectAllClients(DisconnectionContext ctx, bool remove = false)
 {
     for (int i = 0; i < ClientCount; i++)
     {
         while (GlobalDefaults.UseEncryption && !Clients[i].RecivedKey)
         {
             ;
         }
         lock (LockObject)
         {
             Clients[i].Disconnect(ctx);
             if (remove)
             {
                 Clients.RemoveAt(i);
                 i--;
             }
         }
     }
     if (remove && RestartAutomatically && !Running && ClientCount < MaxClients)
     {
         StartServer();
     }
 }