Ejemplo n.º 1
0
        public void StartListening(Action <_TClientContext> connectionHandler)
        {
            using (EneterTrace.Entering())
            {
                try
                {
                    using (ThreadLock.Lock(myListeningManipulatorLock))
                    {
                        if (IsListening)
                        {
                            string aMessage = TracedObject + ErrorHandler.IsAlreadyListening;
                            EneterTrace.Error(aMessage);
                            throw new InvalidOperationException(aMessage);
                        }

                        if (connectionHandler == null)
                        {
                            throw new ArgumentNullException("The input parameter connectionHandler is null.");
                        }

                        myConnectionHandler = connectionHandler;

                        HostListenerController.StartListening(Address, myHostListenerFactory, myConnectionHandler, mySecurityFactory);
                    }
                }
                catch (Exception err)
                {
                    EneterTrace.Error(TracedObject + ErrorHandler.FailedToStartListening, err);
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
 public void StopListening()
 {
     using (EneterTrace.Entering())
     {
         try
         {
             using (ThreadLock.Lock(myListeningManipulatorLock))
             {
                 HostListenerController.StopListening(Address);
                 myConnectionHandler = null;
             }
         }
         catch (Exception err)
         {
             EneterTrace.Warning(TracedObject + ErrorHandler.IncorrectlyStoppedListening, err);
         }
     }
 }