Пример #1
0
 private void AcceptCallBack(IAsyncResult ar)
 {
     try
     {
         Client_TCP temp_client = new Client_TCP(Listener.EndAccept(ar));
         Listener.BeginAccept(new AsyncCallback(AcceptCallBack), Listener);
         if (OnRemoteDisconnect != null)
         {
             temp_client.OnRemoteDisconnect += OnRemoteDisconnect;
         }
         if (OnClientsReceive != null)
         {
             temp_client.OnReceive += OnClientsReceive;
         }
         if (OnDropped != null)
         {
             temp_client.OnDropped += OnDropped;
         }
         Clients.Add(temp_client);
         if (OnAcceptNewClient != null)
         {
             OnAcceptNewClient(temp_client);
         }
         temp_client.Receive();
     }
     catch
     {
         Listener.BeginAccept(new AsyncCallback(AcceptCallBack), Listener);
         if (OnAcceptClientFail != null)
         {
             OnAcceptClientFail();
         }
     }
 }
Пример #2
0
 private void AcceptCallBack(IAsyncResult ar)
 {
     Client_TCP temp_client = new Client_TCP();
     try
     {
         temp_client.socket = Listener.EndAccept(ar);
     }
     catch
     {
         Listener.Dispose();
         return;
     }
     Listener.BeginAccept(new AsyncCallback(AcceptCallBack), Listener);
     if (OnClientsReceiveMsg != null)
     {
         temp_client.OnReceiveMsg += OnClientsReceiveMsg;
     }
     Clients.Add(temp_client);
     temp_client.Receive();
     if (OnClientDisconnect != null)
     {
         temp_client.OnDisconnect += OnClientDisconnect;
     }
     if (OnListenSuccess != null)
     {
         OnListenSuccess();
     }
     if(OnAcceptNewClient != null)
     {
         OnAcceptNewClient(temp_client);
     }
 }
Пример #3
0
            private void AcceptCallBack(IAsyncResult ar)
            {
                try
                {
                    Client_TCP temp_client = new Client_TCP(Listener.EndAccept(ar));
                    Listener.BeginAccept(new AsyncCallback(AcceptCallBack), Listener);
                    temp_client.IP = temp_client.Get_RemoteIP();
                    temp_client.OnServerDisconnect += Temp_client_OnServerDisconnect;
                    temp_client.OnDropped += Temp_client_OnDropped;
                    if (OnReceive != null)
                    {
                        temp_client.OnReceive += OnReceive;
                    }
                    Clients.Add(temp_client);
                    if (OnAddNewClient != null)
                    {
                        OnAddNewClient(temp_client);
                    }
                    temp_client.Receive();
                }
                catch
                {

                }
            }