private void ActivateServiceHandler(IServiceHandler serviceHandler)
 {
     if (serviceHandler.Handle.UserSocket.Connected)
     {
         log.Info("ServiceHandler connected.");
         serviceHandler.Open();
         AcceptNotification?.Invoke();
     }
     else
     {
         log.Warn("ServiceHandler not connected.");
         serviceHandler.Dispose();
         serviceHandler = null;
     }
 }
 protected virtual void ConnectServiceHandler(IServiceHandler serviceHandler,
                                              EndPoint remoteAddress, Connection_Mode mode)
 {
     try
     {
         serviceHandler.Handle.Connect(remoteAddress);
         ActivateServiceHandler(serviceHandler);
     }
     catch (SocketException ex)
     {
         if (ex.SocketErrorCode == SocketError.WouldBlock && mode == Connection_Mode.ASYNC)
         {
             reactor.RegisterHandler(serviceHandler, EventType.CONNECT_EVENT);
             serviceHandler.ConnectionNotification += Complete;
             connectionMap[serviceHandler.Handle]   = serviceHandler;
         }
         else
         {
             log.Error(ex, String.Format("Connector Socket Error has occurred with WSAError - {0}", ex.SocketErrorCode.ToString()));
             serviceHandler?.Dispose();
         }
     }
 }
Exemplo n.º 3
0
 public void Dispose()
 {
     RemoveEventHandlerNotifications(serviceHandler);
     serviceHandler.Dispose();
     reactor.Dispose();
 }