/// <summary> /// Dispose managed resources. /// </summary> /// <param name="disposing">Is desposing.</param> protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { CancelPolling(); if (pubSocket != null) { pubSocket.Disconnect(PublisherAddress); pubSocket.Dispose(); pubSocket = null; } if (poller != null) { poller.Dispose(); poller = null; } if (context != null) { context.Terminate(); context.Dispose(); context = null; } if (source != null) { source.Dispose(); source = null; } } // Shared cleanup logic. disposed = true; } }
public void Stop() { _subscribeThreadCancellation.Cancel(); _pingThreadCancellation.Cancel(); _subscribeThread.Join(); _pingThread.Join(); _subscribeThreadCancellation.Dispose(); _pingThreadCancellation.Dispose(); lock (_publishSocketLocker) { _publishSocket?.Disconnect(_publishAddress); } _subscribeSocket?.Disconnect(_subscribeAddress); lock (_publishSocketLocker) { _publishSocket?.Dispose(); } _subscribeSocket?.Dispose(); _messageHost?.Stop(); }
protected override void disconnectClose() { if (sender != null) { // TODO: check first if closed sender.Disconnect("tcp://" + IP + ":" + Port); sender.Close(); sender.Dispose(); sender = null; } //NetMQConfig.Cleanup(); }
private void ClearDeadNodes(object sender, NetMQTimerEventArgs e) { // create an array with the dead nodes var deadNodes = m_nodes. Where(n => DateTime.Now > n.Value + m_deadNodeTimeout) .Select(n => n.Key).ToArray(); // remove all the dead nodes from the nodes list and disconnect from the publisher foreach (var node in deadNodes) { m_nodes.Remove(node); m_publisher.Disconnect(node.Address); m_shim.SendMoreFrame(RemovedNodeCommand).SendFrame(node.Address); } }
public void Stop() { try { _poller.Stop(); _publisherSocket.Disconnect(_publisherAddress); _dealerSocket.Disconnect(_dealerAddress); _poller.Dispose(); _publisherSocket.Dispose(); _dealerSocket.Dispose(); } finally { NetMQConfig.Cleanup(); } }
private void Cleanup(object sender, NetMQTimerEventArgs e) { _logger?.LogDebug($"{_id}: Running peer cleanup on thread {Thread.CurrentThread.Name}"); var unresponsivePeers = _info.Where(n => DateTimeOffset.Now > n.Value + _peerLifetime) .Select(n => n.Key); foreach (var peer in unresponsivePeers) { _info.Remove(peer); _publisher.Disconnect(peer.Address); _shim.SendMoreFrame("R").SendFrame(peer.Address); _logger?.LogInformation($"{_id}: Removed unresponsive peer at '{{PeerAddress}}'", peer.Address); _hub?.Clients.All.SendAsync("ReceiveMessage", "warning", $"Removing unresponsive peer at '{peer.Address}'"); } }
private void ClearDeadNodes(object sender, NetMQTimerEventArgs e) { //Console.WriteLine(""); //Console.WriteLine($"ClearDeadNodes"); var now = DateTime.Now; //DumpNodes(now, "BeforeClearDateNodes"); // create an array with the dead nodes var deadNodes = nodes.Where(n => now > n.Value + m_deadNodeTimeout) .Select(n => n.Key) .ToArray(); // remove all the dead nodes from the nodes list and disconnect from the publisher foreach (var node in deadNodes) { nodes.Remove(node); publisher.Disconnect(node.Address); shim.SendMoreFrame(RemovedNodeCommand).SendFrame(node.Address); } //DumpNodes(now, "AfterClearDateNodes"); }
protected override void OnStop(PublisherSocket socket) { socket.Disconnect(_connectAddress); }