Пример #1
0
 private void Server_ClientDisconnected(object sender, ServerClientEventArgs e)
 {
     try
     {
         HiveCommunicationServerClient lvClient = this.FindClient(e.Client.ClientId);
         if (lvClient != null)
         {
             InputHiveServerForm.LoggingQueue.Enqueue(String.Format(
                                                          "{0} {1} disconnected. ID: {2} IP: {3}", DateTime.Now, lvClient.Username,
                                                          lvClient.ClientInformation.ClientId, lvClient.ClientInformation.RemoteEndPoint));
             this.ChatToAllClients(String.Format("{0} disconnected.", lvClient.Username));
             foreach (HiveCommunicationServerClient lvC in this.Clients)
             {
                 if (lvC.ClientInformation.ClientId == e.Client.ClientId)
                 {
                     this.Clients.Remove(lvC);
                     break;
                 }
             }
             if (this.UpdateClientEvent != null)
             {
                 this.UpdateClientEvent.Invoke();
             }
         }
     }
     catch (Exception lvEx)
     { throw new Exception("Error when a client disconnected: " + lvEx.Message); }
 }
Пример #2
0
 public void KickClient(HiveCommunicationServerClient pClient)
 {
     InputHiveServerForm.LoggingQueue.Enqueue(String.Format(
                                                  "{0} Kicked client: {1}", DateTime.Now, pClient));
     pClient.ClientInformation.SendMessage(new ScsTextMessage("kick"));
     pClient.ClientInformation.Disconnect();
     if (this.UpdateClientEvent != null)
     {
         this.UpdateClientEvent.Invoke();
     }
 }
Пример #3
0
 public void BanClient(HiveCommunicationServerClient pClient)
 {
     this.BannedIps.Add(pClient.ClientInformation.RemoteEndPoint.ToString());
     InputHiveServerForm.LoggingQueue.Enqueue(String.Format(
                                                  "{0} Banned client: {1}", DateTime.Now, pClient));
     pClient.ClientInformation.SendMessage(new ScsTextMessage("ban"));
     pClient.ClientInformation.Disconnect();
     if (this.UpdateClientEvent != null)
     {
         this.UpdateClientEvent.Invoke();
     }
 }