void CliManagement_ClientConnected(Client client)
 {
     ListViewItem item = new ListViewItem();
     item.Text = client.ClientID;
     item.SubItems.Add(client.SocketClient.Client.RemoteEndPoint.ToString());
     item.SubItems.Add(client.SocketClient.Client.LocalEndPoint.ToString());
     ClientslistView.Items.Add(item);
 }
 void CliManagement_ClientConnectionEnded(Client sender)
 {
     for (int i = 0; i < ClientslistView.Items.Count; i++)
     {
         if (ClientslistView.Items[i].Text == sender.ClientID)
         {
             ClientslistView.Items[i].Remove();
             break;
         }
     }
 }
 protected virtual void OnClientConnected(Client cli)
 {
     if (ClientConnected != null)
         ClientConnected(this, cli);
 }
        public void addClient(Client client)
        {
            if (ConexionState)
            {
                WriteLine("Client \"" + client.ClientID + "\" connected!");

                client.ClientMessageReceived += new Client.ClientMessageReceivedEventHandler(client_ClientMessageReceived);
                client.ClientEndedConnection += new Client.ClientConnectionEndedEventHandler(client_ClientEndedConnection);

                if (!client.Cli_Listener.isRunning())
                    client.Cli_Listener.StartListeningClient();

                Client_List.Add(client.ClientID, client);
            }
            else
            {
                client.CloseConnection();
            }
        }
 void ServListener_ClientConnected(ServeurListener sender, Client cli)
 {
     OnClientConnected(cli);
     addClient(cli);
 }
 void client_ClientMessageReceived(Client sender, NetMessage cliMsg)
 {
     WriteLine(sender.ClientID + " : posX->" + cliMsg.PosX.ToString() + ", posY->" + cliMsg.PosY.ToString());
     OnClientMessageReceived(sender, cliMsg);
 }
 void client_ClientEndedConnection(Client sender)
 {
     OnClientConnectionEnded(sender);
     WriteLine(sender.ClientID + " disconnected!");
     delClient(sender);
 }
 protected virtual void OnClientMessageReceived(Client sender, NetMessage cliMsg)
 {
     if (ClientMessageReceived != null)
         ClientMessageReceived(sender, cliMsg);
 }
 protected virtual void OnClientConnectionEnded(Client sender)
 {
     if (ClientConnectionEnded != null)
         ClientConnectionEnded(sender);
 }
 protected virtual void OnClientConnected(Client client)
 {
     if (ClientConnected != null)
         ClientConnected(client);
 }
 public void delClient(Client cli)
 {
     lock (locker)
     {
         if (Client_List.ContainsKey(cli.ClientID))
             Client_List.Remove(cli.ClientID);
     }
 }
 public void BroadcastMessage(String msg, Client ClientToExclude)
 {
     lock (locker)
     {
         foreach (Client cli in Client_List.Values)
         {
             if (cli.ClientID != ClientToExclude.ClientID)
                 cli.Cli_Sender.SendMessage(msg);
         }
     }
 }