public bool Ping(Guid managementAgentID) { IEventCallBack subscriber = OperationContext.Current.GetCallbackChannel <IEventCallBack>(); if (EventService.subscribers.ContainsKey(managementAgentID)) { if (EventService.subscribers[managementAgentID].Contains(subscriber)) { // Still registered logger.Trace($"Client ping succeeded for {managementAgentID} at {EventService.RemoteHost}"); return(true); } } logger.Warn($"Client ping failed for {managementAgentID} at {EventService.RemoteHost}. Client is no longer registered."); // Not registered return(false); }
public void Register(Guid managementAgentID) { try { string name = Global.GetManagementAgentName(managementAgentID); if (name == null) { throw new NoSuchManagementAgentException(); } IEventCallBack subscriber = OperationContext.Current.GetCallbackChannel <IEventCallBack>(); if (!EventService.subscribers.ContainsKey(managementAgentID)) { EventService.subscribers.TryAdd(managementAgentID, new SynchronizedCollection <IEventCallBack>()); } if (!EventService.subscribers[managementAgentID].Contains(subscriber)) { EventService.subscribers[managementAgentID].Add(subscriber); } // ReSharper disable once SuspiciousTypeConversion.Global if (subscriber is ICommunicationObject commObj) { commObj.Faulted += EventService.CommObj_Faulted; commObj.Closed += EventService.CommObj_Closed; } logger.Trace($"Registered callback channel for {name}/{managementAgentID} on client {EventService.RemoteHost}"); } catch (Exception ex) { logger.Error(ex, "An error occurred with the client registration"); throw; } }