Exemplo n.º 1
0
 private void AcceptProcess(System.Net.Sockets.Socket e)
 {
     try
     {
         EventArgs.ConnectingEventArgs cea = new EventArgs.ConnectingEventArgs();
         cea.Server = this;
         cea.Socket = e;
         OnConnecting(cea);
         if (cea.Cancel)
         {
             if (EnableLog(LogType.Debug))
             {
                 Log(LogType.Debug, null, "cancel {0} connect", e.RemoteEndPoint);
             }
             CloseSocket(e);
         }
         else
         {
             ConnectedProcess(e);
             if (EnableLog(LogType.Debug))
             {
                 Log(LogType.Debug, null, "{0} connected", e.RemoteEndPoint);
             }
         }
     }
     catch (Exception e_)
     {
         if (EnableLog(LogType.Error))
         {
             Error(e_, null, "accept socket process error");
         }
     }
 }
Exemplo n.º 2
0
 private void AcceptProcess(AcceptSocketInfo e)
 {
     try
     {
         EventArgs.ConnectingEventArgs cea = new EventArgs.ConnectingEventArgs();
         cea.Server = this;
         cea.Socket = e.Socket;
         EndPoint endPoint = e.Socket.RemoteEndPoint;
         OnConnecting(cea);
         if (cea.Cancel)
         {
             if (EnableLog(LogType.Debug))
             {
                 Log(LogType.Debug, null, $"cancel {endPoint} connect");
             }
             CloseSocket(e.Socket);
         }
         else
         {
             if (e.Socket.Connected)
             {
                 ConnectedProcess(e);
                 if (EnableLog(LogType.Debug))
                 {
                     Log(LogType.Debug, null, $" {endPoint} connected");
                 }
             }
             else
             {
                 if (EnableLog(LogType.Info))
                 {
                     Log(LogType.Info, null, $"Connected process {endPoint} is disconnected");
                 }
             }
         }
     }
     catch (Exception e_)
     {
         if (EnableLog(LogType.Error))
         {
             Error(e_, null, "accept socket process error");
         }
     }
 }
Exemplo n.º 3
0
 private void AcceptProcess(System.Net.Sockets.Socket e)
 {
     try
     {
         EventArgs.ConnectingEventArgs cea = new EventArgs.ConnectingEventArgs();
         cea.Server = this;
         cea.Socket = e;
         OnConnecting(cea);
         if (cea.Cancel)
         {
             CloseSocket(e);
         }
         else
         {
             ConnectedProcess(e);
         }
     }
     catch (Exception e_)
     {
         Error(e_, null, "accept socket process error");
     }
 }