Exemplo n.º 1
0
        public void Dispose()
        {
            Disconnect();

            if (_reqSocket != null)
            {
                _reqSocket.Dispose();
                _reqSocket = null;
            }
            if (_subSocket != null)
            {
                _subSocket.Dispose();
                _subSocket = null;
            }
            if (_dealerSocket != null)
            {
                _dealerSocket.Dispose();
                _dealerSocket = null;
            }
            if (_heartBeatTimer != null)
            {
                _heartBeatTimer.Dispose();
                _heartBeatTimer = null;
            }
            //The context must be disposed of last! It will hang if the sockets have not been disposed.
            if (_context != null)
            {
                _context.Dispose();
                _context = null;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Disconnect peer mailbox
 /// No more messages will be sent to peer until connected again
 /// </summary>
 public void Disconnect()
 {
     m_mailbox.Dispose();
     m_mailbox   = null;
     m_endpoint  = null;
     m_connected = false;
     m_ready     = false;
 }
Exemplo n.º 3
0
        public void Shutdown()
        {
            if (_socket != null)
            {
                try
                {
                    _socket.Close();
                }
                catch (Exception)
                {
                }

                try
                {
                    _socket.Dispose();
                }
                catch (Exception)
                {
                }
            }
            _socket   = null;
            _finished = true;
            _worker.Join();
            NetMQConfig.Cleanup(true);
        }
Exemplo n.º 4
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();
                    }
                }
            }
        }
Exemplo n.º 5
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;
            }

            _mailbox?.Dispose();
        }
Exemplo n.º 6
0
        private void ProxyThread()
        {
            RouterSocket router = null;
            DealerSocket dealer = null;

            try
            {
                router = _ctx.CreateRouterSocket();
                dealer = _ctx.CreateDealerSocket();
                router.Bind(_frontendAddress);
                switch (_backendCxMode)
                {
                case ConnectionMode.Connect:
                    dealer.Connect(_backendAddress);
                    break;

                case ConnectionMode.Bind:
                    dealer.Bind(_backendAddress);
                    break;
                }

                router.Options.Linger = TimeSpan.Zero;
                dealer.Options.Linger = TimeSpan.Zero;
                var xproxy = new Proxy(router, dealer, null);
                xproxy.Start();
            }
            catch (TerminatingException)
            {
            }
            finally
            {
                if (router != null)
                {
                    try
                    {
                        router.Dispose();
                    }
                    catch (NetMQException)
                    {
                    }
                }
                if (dealer != null)
                {
                    try
                    {
                        dealer.Dispose();
                    }
                    catch (NetMQException)
                    {
                    }
                }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// Disconnect peer mailbox
 /// No more messages will be sent to peer until connected again
 /// </summary>
 internal void Disconnect()
 {
     if (Connected)
     {
         _loggerDelegate?.Invoke($"{nameof(ZyrePeer)}.{nameof(Disconnect)}() disposing mailbox for peer={this}");
         _mailbox.Dispose();
         _mailbox  = null;
         Endpoint  = null;
         Connected = false;
         Ready     = false;
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// If disposing equals true, the method has been called directly or indirectly by a user's code.
        /// Managed and unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    _subscriberSocket?.Dispose();
                    _dealerSocket?.Dispose();
                }

                _isDisposed = true;
            }
        }
Exemplo n.º 9
0
        public override Task Stop()
        {
            _cancel.Cancel();

            _poller.Stop();

            _client.Close();
            _client.Dispose();

            _isConnected.OnCompleted();
            _isConnected.Dispose();

            return(Task.CompletedTask);
        }
Exemplo n.º 10
0
        public void NetMQSender_WithMissingSerializer_ThrowsArgumentNullException()
        {
            // Arrange
            var socket = new DealerSocket();

            // Act
            TestDelegate construct = () => new NetMQSender(socket, null);

            // Assert
            Assert.That(construct, Throws.ArgumentNullException);

            // Cleanup
            socket.Dispose();
        }
Exemplo n.º 11
0
        public void Stop()
        {
            try
            {
                _poller.Stop();
                _publisherSocket.Disconnect(_publisherAddress);
                _dealerSocket.Disconnect(_dealerAddress);

                _poller.Dispose();
                _publisherSocket.Dispose();
                _dealerSocket.Dispose();
            }
            finally
            {
                NetMQConfig.Cleanup();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Cleans up resources
        /// </summary>
        private void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    TerminateConnection();
                    if (!(socket is null))
                    {
                        socket.ReceiveReady -= PendingMessage;
                        socket.Dispose();
                    }
                    socket = null;
                }

                disposedValue = true;
            }
        }
Exemplo n.º 13
0
        private Task Cleanup()
        {
            _cancel.Cancel();

            if (null != _getMarketState)
            {
                _getMarketState.Close();
                _getMarketState.Dispose();
            }

            if (null != _getMarketUpdates)
            {
                _getMarketUpdates.Close();
                _getMarketUpdates.Dispose();
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Shut down the service and clean up resources.
        /// </summary>
        public void Stop()
        {
            if (IsRunning)
            {
                try
                {
                    _poller.Stop();
                    _subscriberSocket.Disconnect(_publisherAddress);
                    _dealerSocket.Disconnect(_dealerAddress);

                    _poller.Dispose();
                    _subscriberSocket.Dispose();
                    _dealerSocket.Dispose();
                }
                finally
                {
                    IsRunning = false;
                    NetMQConfig.Cleanup();
                }
            }
        }
Exemplo n.º 15
0
 protected override void Cleanup()
 {
     m_clientSocket.Dispose();
 }
Exemplo n.º 16
0
 public override void Dispose()
 {
     poller?.Dispose();
     dealerSocket?.Dispose();
     routerSocket?.Dispose();
 }
Exemplo n.º 17
0
 public void Dispose()
 {
     clientSocket?.Disconnect(connectionString);
     clientSocket?.Dispose();
 }
Exemplo n.º 18
0
 protected override void Cleanup()
 {
     m_workerSocket.Dispose();
 }
Exemplo n.º 19
0
 public void Dispose()
 {
     _input?.Dispose();
     _output?.Dispose();
 }
Exemplo n.º 20
0
 private void DisposeSocket()
 {
     try { _socket?.Dispose(); } catch { }
 }