Ejemplo n.º 1
0
        private void Disconnect(PeerId peerId, bool delayed = true)
        {
            if (_outboundSockets.ContainsKey(peerId))
            {
                _logger.InfoFormat("Queueing disconnect, PeerId: {0}, Delayed: {1}", peerId, delayed);
            }

            if (delayed)
            {
                SafeAdd(_pendingDisconnects, new PendingDisconnect(peerId, SystemDateTime.UtcNow.Add(_configuration.WaitForEndOfStreamAckTimeout)));
            }
            else
            {
                SafeAdd(_outboundSocketActions, OutboundSocketAction.Disconnect(peerId));
            }
        }
Ejemplo n.º 2
0
        private void DisconnectProc()
        {
            Thread.CurrentThread.Name = "ZmqTransport.DisconnectProc";

            foreach (var pendingDisconnect in _pendingDisconnects.GetConsumingEnumerable())
            {
                while (pendingDisconnect.DisconnectTimeUtc > SystemDateTime.UtcNow)
                {
                    if (_pendingDisconnects.IsAddingCompleted)
                    {
                        return;
                    }

                    Thread.Sleep(500);
                }

                SafeAdd(_outboundSocketActions, OutboundSocketAction.Disconnect(pendingDisconnect.PeerId));
            }
        }