예제 #1
0
 public void Dispose()
 {
     _openSocket.Dispose();
     _authSocket.Dispose();
     _openMessenger.Dispose();
     _authMessenger.Dispose();
 }
예제 #2
0
 public void Dispose()
 {
     if (!_keepPublisherOpen)
     {
         _parentPublisher.Dispose();
     }
 }
예제 #3
0
        private static void SendMessages(MessengerFactory factory,
                                         string[] messages,
                                         Identity identity,
                                         string to,
                                         string messengerType)
        {
            IMessenger messenger = null;

            try {
                messenger = factory.GetMessenger(messengerType, identity);
                foreach (var message in messages)
                {
                    try {
                        messenger.Send(new SendParamater(to: to, message: message));
                    } catch (Exceptions.ConnectionException exception) {
                        Logger.Error(exception: exception);
                    }
                }
            } catch (Exceptions.ConnectionException exception) {
                Logger.Error(exception: exception);
            } finally {
                if (messenger != null)
                {
                    messenger.Dispose();
                }
            }
        }
예제 #4
0
        public void Dispose()
        {
            if (Messenger != null)
            {
                Messenger.Dispose();
            }

            Directory.Delete(_testDir, true);
        }
예제 #5
0
        public async Task Stop()
        {
            if (_messenger != null)
            {
                await _messenger.Disconnect();

                _messenger.Dispose();
            }
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         // Dispose managed resources
         if (Messenger != null)
         {
             Messenger.Dispose();
             Messenger = null;
         }
     }
     base.Dispose(disposing);
 }
예제 #7
0
        private static void Main(string[] args)
        {
            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                logger.Info("Shutting down...");
                if (messenger != null)
                {
                    messenger.Dispose();
                }
                Environment.Exit(0);
            };

            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                logger.Error(e.ExceptionObject);
                if (messenger != null)
                {
                    messenger.SendMessage("Farewell, cruel world!", "#botulism");
                    messenger.SendMessage(((Exception)e.ExceptionObject).Message, "#rob");
                    messenger.Dispose();
                }
                Environment.Exit(0);
            };

            logger.Info("Starting up... ");

            var container = CreateContainer();

            container.Verify();
#if DEBUG
            messenger = new ConsoleMessenger();
#else
            // TODO: Select implementation at run-time
            messenger = new IrcMessenger();
#endif

            var pipeline = container.GetInstance <IMessageProcessOverseer>();

            var modules      = container.GetAllInstances <IModule>().ToList();
            var listeners    = modules.SelectMany(mo => mo.GetMessageListeners());
            var producers    = modules.SelectMany(mo => mo.GetMessageProducers());
            var reactors     = modules.SelectMany(mo => mo.GetMessageReactors());
            var transformers = modules.SelectMany(mo => mo.GetMessageTransformers());

            foreach (var listener in listeners)
            {
                pipeline.AddListener(listener);
            }

            foreach (var producer in producers)
            {
                pipeline.AddProducer(producer);
            }

            foreach (var reactor in reactors)
            {
                pipeline.AddReactor(reactor);
            }

            foreach (var transformer in transformers)
            {
                pipeline.AddTransformer(transformer);
            }

            messenger.MessageReceived += (sender, eventArgs) =>
                                         pipeline.Process(messenger,
                                                          eventArgs.Message,
                                                          eventArgs.Addressed);

            Thread.Sleep(Timeout.Infinite);
        }
예제 #8
0
 public void Dispose()
 {
     _networker.Dispose();
 }