Пример #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;
            }
        }
Пример #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;
 }
Пример #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);
        }
Пример #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();
                    }
                }
            }
        }
Пример #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();
        }
Пример #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)
                    {
                    }
                }
            }
        }
Пример #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;
     }
 }
Пример #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;
            }
        }
Пример #9
0
        public override Task Stop()
        {
            _cancel.Cancel();

            _poller.Stop();

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

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

            return(Task.CompletedTask);
        }
Пример #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();
        }
Пример #11
0
        public void Stop()
        {
            try
            {
                _poller.Stop();
                _publisherSocket.Disconnect(_publisherAddress);
                _dealerSocket.Disconnect(_dealerAddress);

                _poller.Dispose();
                _publisherSocket.Dispose();
                _dealerSocket.Dispose();
            }
            finally
            {
                NetMQConfig.Cleanup();
            }
        }
Пример #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;
            }
        }
Пример #13
0
        private Task Cleanup()
        {
            _cancel.Cancel();

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

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

            return(Task.CompletedTask);
        }
Пример #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();
                }
            }
        }
Пример #15
0
 protected override void Cleanup()
 {
     m_clientSocket.Dispose();
 }
Пример #16
0
 public override void Dispose()
 {
     poller?.Dispose();
     dealerSocket?.Dispose();
     routerSocket?.Dispose();
 }
Пример #17
0
 public void Dispose()
 {
     clientSocket?.Disconnect(connectionString);
     clientSocket?.Dispose();
 }
Пример #18
0
 protected override void Cleanup()
 {
     m_workerSocket.Dispose();
 }
Пример #19
0
 public void Dispose()
 {
     _input?.Dispose();
     _output?.Dispose();
 }
Пример #20
0
 private void DisposeSocket()
 {
     try { _socket?.Dispose(); } catch { }
 }