/// <summary> /// Unsubscribes the calling client from the logger. /// </summary> /// <remarks> /// Unregisters the event handler for the item, removes the client to the SignalR group for the item's FQN, /// unsubscribes the client from the item within the HubManager and calls the unsubscribeSuccess() method on the /// calling client. /// </remarks> public void Unsubscribe(object arg) { Groups.Remove(Context.ConnectionId, "Logger"); hubManager.Unsubscribe("Logger", Context.ConnectionId); Clients.Caller.unsubscribeSuccess("Logger"); logger.Info(GetLogPrefix() + "unsubscribed from the Logger."); logger.Info("SignalR Logger now has " + hubManager.GetSubscriptions("Logger").Count + " subscriber(s)."); }
/// <summary> /// Unsubscribes the calling client from the item matching the provided FQN. /// </summary> /// <remarks> /// Unregisters the event handler for the item, removes the client to the SignalR group for the item's FQN, /// unsubscribes the client from the item within the HubManager and calls the unsubscribeSuccess() method on the /// calling client. /// </remarks> /// <param name="arg">the Fully Qualified Name of the item to which the client is to be unsubscribed.</param> public void Unsubscribe(object arg) { string castFQN = (string)arg; // Item foundItem = manager.ProviderRegistry.FindItem(castFQN); Item foundItem = manager.GetManager <IModelManager>().FindItem(castFQN); if (foundItem != default(Item)) { foundItem.Changed -= hubManager.OnChange; Groups.Remove(Context.ConnectionId, foundItem.FQN); hubManager.Unsubscribe(foundItem.FQN, Context.ConnectionId); Clients.Caller.unsubscribeSuccess(castFQN); logger.Info(GetLogPrefix() + "unsubscribed from '" + foundItem.FQN + "'."); logger.Info("SignalR Item '" + foundItem.FQN + "' now has " + hubManager.GetSubscriptions(foundItem.FQN)?.Count ?? 0 + " subscriber(s)."); } else { Clients.Caller.unsubscribeError(castFQN); logger.Info("Unable to unsubscribe from '" + castFQN + "'; the Item can't be found."); } }