Ejemplo n.º 1
0
        public void StopServer()
        {
            if (!ServerRunning)
            {
                return;
            }

            poller?.Stop();
            poller?.Dispose();

            lock (responseSocketLock)
            {
                if (responseSocket != null)
                {
                    try
                    {
                        responseSocket.Disconnect(responseSocketConnectionString);
                    }
                    finally
                    {
                        responseSocket.Close();
                        responseSocket = null;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     _cancellationSource.Dispose();
     _poller.Stop();
     _poller.Dispose();
     _socket.Dispose();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Release any contained resources.
        /// </summary>
        /// <param name="disposing">true if managed resources are to be released</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            if (_isRunning)
            {
                Stop();
            }
            if (_poller.IsRunning)
            {
                _poller?.Stop();
            }
            _poller?.Dispose();
            _beacon?.Dispose();
            _inbox?.Dispose();
            _outbox?.Dispose();
            foreach (var peer in _peers.Values)
            {
                peer.Destroy();
            }
            foreach (var group in _peerGroups.Values)
            {
                group.Dispose();
            }
            foreach (var group in _ownGroups.Values)
            {
                group.Dispose();
            }
        }
Ejemplo n.º 4
0
 private void StopQueryMQ()
 {
     try
     {
         if (null != _queryPoller)
         {
             if (null != _querySocket)
             {
                 _queryPoller.Remove(_querySocket);
             }
             if (_queryPoller.IsRunning)
             {
                 _queryPoller.Stop();
             }
             _queryPoller.Dispose();
             _queryPoller = null;
         }
         if (null != _querySocket)
         {
             _querySocket.ReceiveReady -= _querySocket_ReceiveReady;
             _querySocket.SendReady    -= _querySocket_SendReady;
             //_querySocket.Disconnect(_querySocket.Options.LastEndpoint);
             _querySocket.Dispose();
             _querySocket = null;
         }
         _queryMsgList.Clear();
     }
     catch (Exception ex)
     {
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        ///     Stop the server.
        /// </summary>
        public void StopServer()
        {
            if (!ServerRunning)
            {
                return;
            }

            _poller?.Stop();
            _poller?.Dispose();

            lock (_socketLock)
            {
                if (_socket != null)
                {
                    try
                    {
                        _socket.Disconnect(_connectionString);
                    }
                    finally
                    {
                        _socket.ReceiveReady -= SocketReceiveReady;
                        _socket.Close();
                        _socket = null;
                    }
                }
            }

            _poller = null;
        }
 public void Disconnect()
 {
     pushSocket?.Disconnect(pushConnectionString);
     poller?.Stop();
     poller?.Dispose();
     pushSocket?.Dispose();
 }
Ejemplo n.º 7
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                _disposed = true; //prevent second call to Dispose
                if (disposing)
                {
                    if (null != _heartBeatTimer)
                    {
                        _heartBeatTimer.Enable = false;
                    }
                    if (null != _socketPoller)
                    {
                        _socketPoller.Dispose();
                    }
                    if (null != _sendQueue)
                    {
                        _sendQueue.Dispose();
                    }
                    if (null != _dealerSocket)
                    {
                        _dealerSocket.Dispose();
                    }

                    if (null != _clientPoller)
                    {
                        _clientPoller.Dispose();
                    }
                    if (null != _receiveQueue)
                    {
                        _receiveQueue.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public virtual void Stop()
        {
            GlobalServerProxy?.Stop();

            Poller?.Stop();
            Poller?.Dispose();
            Poller = null;
        }
Ejemplo n.º 9
0
 /// <summary>
 ///
 /// </summary>
 public void Stop()
 {
     if (m_started)
     {
         m_poller.Dispose();
         m_server.Dispose();
         m_started = false;
     }
 }
Ejemplo n.º 10
0
 public void Dispose()
 {
     _actor?.Dispose();
     _publisher?.Dispose();
     _subscriber?.Dispose();
     _beacon?.Dispose();
     _poll?.Dispose();
     _shim?.Dispose();
 }
Ejemplo n.º 11
0
 public void Cleanup()
 {
     if (isIgniteBotEmbedded && !hasCleanedUp)
     {
         poller.StopAsync();
         Thread.Sleep(10);
         subSocket.Dispose();
         poller.Dispose();
         NetMQConfig.Cleanup(false);
         hasCleanedUp = true;
     }
 }
Ejemplo n.º 12
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_IsDisposed)
     {
         if (disposing)
         {
             Poller?.Dispose();
             Socket?.Dispose();
         }
         _IsDisposed = true;
     }
 }
Ejemplo n.º 13
0
        public void Stop()
        {
            if (!IsRunning)
            {
                return;
            }

            this._nodes.Clear();

            _poller.Stop();
            _beacon.Unsubscribe();
            _poller.Remove(_beacon);
            _poller.Remove(timer);

            _poller.Dispose();
            _poller = null;

            _beacon.Dispose();
            _beacon = null;

            timer = null;
        }
Ejemplo n.º 14
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _poller?.Dispose();
                    _subscriberSocket?.Dispose();
                }

                disposedValue = true;
            }
        }
Ejemplo n.º 15
0
            public void Run(PairSocket shim)
            {
                _poller = new NetMQPoller();

                _ = Observable.FromEventPattern <NetMQSocketEventArgs>(e => shim.ReceiveReady += e, e => shim.ReceiveReady -= e)
                    .Select(e => e.EventArgs)
                    .Subscribe(OnShimReady);

                _poller.Add(shim);

                // Timer
                var timeoutTimer = new NetMQTimer(TimeSpan.FromSeconds(5));

                _ = Observable.FromEventPattern <NetMQTimerEventArgs>(e => timeoutTimer.Elapsed += e, e => timeoutTimer.Elapsed -= e)
                    .Select(e => e.EventArgs)
                    .ObserveOn(ThreadPoolScheduler.Instance)
                    .Subscribe(OnTimeoutElapsed);
                _poller.Add(timeoutTimer);

                _subscriberSocket = new SubscriberSocket();
                _subscriberSocket.Options.Linger = TimeSpan.Zero;
                _subscriberSocket.Subscribe(CoreHearbeatTopic);
                _subscriberSocket.Connect($"tcp://{_address}:{_port + 1}");
                _subject.OnNext(ConnectionStatus.Connecting);

                _ = Observable.FromEventPattern <NetMQSocketEventArgs>(e => _subscriberSocket.ReceiveReady += e, e => _subscriberSocket.ReceiveReady -= e)
                    .Select(e => e.EventArgs)
                    .Where(e => e.Socket.ReceiveFrameString() == CoreHearbeatTopic)
                    .ObserveOn(ThreadPoolScheduler.Instance)
                    .Subscribe(e =>
                {
                    timeoutTimer.Reset();
                    Thread.MemoryBarrier();
                    var status = _borgConnected
                            ? (ConnectionStatus.Online | ConnectionStatus.Connected)
                            : (ConnectionStatus.Online | ConnectionStatus.Disconnected);
                    _subject.OnNext(status);
                });

                _poller.Add(_subscriberSocket);
                timeoutTimer.Reset();
                shim.SignalOK();

                _poller.Run();

                // Cleanup stuff after stopping
                _poller.Remove(_subscriberSocket);
                _poller.Remove(timeoutTimer);
                _poller.Remove(shim);
                _poller.Dispose();
            }
Ejemplo n.º 16
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    _poller?.Dispose();
                    _responseSocket?.Dispose();
                    _publisherSocket?.Dispose();
                }

                disposedValue = true;
            }
        }
Ejemplo n.º 17
0
        private void StopStationNetMQ()
        {
            // HockSocketEvents(false);
            try
            {
                if (null != _poller)
                {
                    if (null != _subscriber)
                    {
                        _poller.Remove(_subscriber);
                    }

                    if (null != _requester)
                    {
                        _poller.Remove(_requester);
                    }

                    //_poller.Remove(_fileSubscriber);

                    if (_poller.IsRunning)
                    {
                        _poller.Stop();
                    }

                    _poller.Dispose();
                    _poller = null;
                }

                if (null != _subscriber)
                {
                    _subscriber.Dispose();
                    _subscriber = null;
                }

                if (null != _requester)
                {
                    _requester.Dispose();
                    _requester = null;
                }

                //_fileSubscriber.Dispose();
                //_fileSubscriber = null;
            }
            catch (Exception err)
            {
                logger.ErrorFormat("Disconnect pub-sub error:{0}", err);
            }

            // this.OnDisconnected();
        }
Ejemplo n.º 18
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _readyGraphUpdates = null;
                _updateThread.Abort();
                _poller.StopAsync();
                _poller.Dispose();
            }
            base.Dispose(disposing);

            _zyre.Dispose();
            NetMQConfig.Cleanup(true);
        }
Ejemplo n.º 19
0
 void OnApplicationQuit()//cleanup
 {
     SceneClient.Close();
     SceneClient.Dispose();
     try
     {
         ScenePoller.StopAsync();
     }
     catch (System.Exception e)
     {
         UnityEngine.Debug.Log("Tried to stopasync while the poller wasn't running! Oops.");
     }
     ScenePoller.Dispose();
     NetMQConfig.Cleanup();
 }
Ejemplo n.º 20
0
        public void TearDown()
        {
            _actorService?.Stop();
            Poller?.Stop();
            PushSocket?.Close();
            PullSocket?.Close();
            Poller?.Dispose();

            PullSocket    = null;
            PushSocket    = null;
            Poller        = null;
            _actorService = null;

            Thread.Sleep(1000);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Cancels Subscription to the topic and closes connections.
 /// </summary>
 public void Stop()
 {
     if (Poller != null)
     {
         Poller.StopAsync();
         Poller.Dispose();
         Poller = null;
     }
     if (Subscriber != null)
     {
         Subscriber.ReceiveReady -= Subscriber_ReceiveReady;
         Subscriber.Unsubscribe(Topic);
         Subscriber.Disconnect("tcp://" + IP + ":" + Port.ToString());
         Subscriber = null;
     }
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Release any contained resources.
        /// </summary>
        /// <param name="disposing">true if managed resources are to be released</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            Stop();
            if (_useEvents)
            {
                _inboxPoller?.StopAsync();
                _inboxPoller?.Dispose();
            }
            _actor?.Dispose();
            _inbox?.Dispose();
        }
Ejemplo n.º 23
0
        public void Stop()
        {
            try
            {
                _poller.Stop();
                _publisherSocket.Disconnect(_publisherAddress);
                _dealerSocket.Disconnect(_dealerAddress);

                _poller.Dispose();
                _publisherSocket.Dispose();
                _dealerSocket.Dispose();
            }
            finally
            {
                NetMQConfig.Cleanup();
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        ///     Stops the server.
        /// </summary>
        public void StopServer()
        {
            if (!ServerRunning)
            {
                return;
            }

            poller?.Stop();
            poller?.Dispose();

            lock (publisherSocketLock)
            {
                if (publisherSocket != null)
                {
                    try
                    {
                        publisherSocket.Disconnect(publisherConnectionString);
                    }
                    finally
                    {
                        publisherSocket.Close();
                        publisherSocket = null;
                    }
                }
            }

            lock (requestSocketLock)
            {
                if (requestSocket != null)
                {
                    try
                    {
                        requestSocket.Disconnect(requestConnectionString);
                    }
                    finally
                    {
                        requestSocket.ReceiveReady -= RequestSocketReceiveReady;
                        requestSocket.Close();
                        requestSocket = null;
                    }
                }
            }

            poller = null;
        }
Ejemplo n.º 25
0
        public void DisposeThrowsIfSocketAlreadyDisposed()
        {
            var socket = new RouterSocket();

            var poller = new NetMQPoller {
                socket
            };

            // Dispose the socket.
            // It is incorrect to have a disposed socket in a poller.
            // Disposed sockets can throw into the poller's thread.
            socket.Dispose();

            // Dispose throws if a polled socket is disposed
            var ex = Assert.Throws <NetMQException>(() => poller.Dispose());

            Assert.AreEqual("Invalid state detected: NetMQPoller contains a disposed NetMQSocket. Sockets must be either removed before being disposed, or disposed after the poller is disposed.", ex.Message);
        }
Ejemplo n.º 26
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            // m_poller might not have been created yet!
            if (!ReferenceEquals(m_poller, null))
            {
                m_poller.Dispose();
            }

            // m_client might not have been created yet!
            if (!ReferenceEquals(m_client, null))
            {
                m_client.Dispose();
            }
        }
 private void StopQueryMQ()
 {
     try
     {
         if (null != _resPoller)
         {
             _resPoller.Stop();
             _resPoller.Remove(_resSocket);
             _resSocket.ReceiveReady -= _resSocket_ReceiveReady;
             _resSocket.Dispose();
             _resPoller.Dispose();
             _resSocket = null;
             _resPoller = null;
         }
     }
     catch (Exception ex)
     {
     }
 }
        public void Dispose()
        {
            if (_beacon != null)
            {
                _beacon.Dispose();
                _beacon = null;
            }

            if (_poller != null)
            {
                _poller.Dispose();
                _poller = null;
            }
            if (_subscriber != null)
            {
                _subscriber.Dispose();
                _subscriber = null;
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        ///     Disconnects from the server.
        /// </summary>
        public void Disconnect()
        {
            if (!PollerRunning)
            {
                return;
            }

            while (RealTimeDataStreams.Count > 0)
            {
                CancelRealTimeData(RealTimeDataStreams.First().Instrument);
            }


            poller?.Stop();
            poller?.Dispose();

            StopSockets();

            poller = null;
        }
Ejemplo n.º 30
0
        public void AddThrowsIfSocketAlreadyDisposed()
        {
            var poller = new NetMQPoller();

            var socket = new RouterSocket();

            // Dispose the socket.
            // It is incorrect to have a disposed socket in a poller.
            // Disposed sockets can throw into the poller's thread.
            socket.Dispose();

            // Adding a disposed socket throws
            var ex = Assert.Throws <ArgumentException>(() => poller.Add(socket));

            Assert.True(ex.Message.StartsWith("Must not be disposed."));
            Assert.AreEqual("socket", ex.ParamName);

            // Still dispose it. It throws after cleanup.
            Assert.Throws <NetMQException>(() => poller.Dispose());
        }