// caller must lock under mu private void cleanupOnClose(Exception ex) { lock (pingLock) { pingTimer?.Dispose(); pingTimer = null; } // Unsubscribe only if we have a connection... if (nc != null && !nc.IsClosed()) { ackSubscription?.Unsubscribe(); pingSubscription?.Unsubscribe(); } // fail all pending pubs... PublishAck pa; var keys = pubAckMap.Keys; foreach (string guid in keys) { if (pubAckMap.Remove(guid, out pa)) { pa.InvokeHandler(guid, ex == null ? "Connection Closed." : ex.Message); } } }
internal PublishAck removeAck(string guid) { PublishAck a; lock (mu) { pubAckMap.Remove(guid, out a, 0); } return(a); }