/// <summary> /// Handles the response received from the service according to the input CommandRecievedEventArgs object. /// </summary> /// <param name="args"></param> private void HandleResponse(CommandRecievedEventArgs args) { try { if (args == null) { return; } switch (args.CommandId) { case (int)CommandEnum.GetLogsCommand: InitializeLogsCollection(args); break; case (int)CommandEnum.NewLog: UpdateLogsCollection(args); break; } NotifyUpdate?.Invoke(); } catch (Exception ex) { Console.WriteLine(ex); } }
/// <summary> /// Closes the handler and removes from the list. /// </summary> /// <param name="args"></param> private void CloseHandler(CommandRecievedEventArgs args) { if (ServiceSettings.Handlers == null || ServiceSettings.Handlers.Count <= 0 || args?.Args == null || !ServiceSettings.Handlers.Contains(args.Args[0])) { return; } ServiceSettings.Handlers.Remove(args.Args[0]); NotifyUpdate?.Invoke(); }
public void UnsubscribeFromChannels(string subscriptionId, string[] channels) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (channels == null) { throw new ArgumentNullException(nameof(channels)); } var sub = GetSubscription(subscriptionId); if (sub == null || channels.Length == 0) { return; } lock (sub) { foreach (var channel in channels) { if (!sub.Channels.Contains(channel)) { continue; } UnRegisterSubscription(sub, channel, ChannelSubcriptions); } var subChannels = sub.Channels.ToList(); subChannels.RemoveAll(channels.Contains); sub.UpdateChannels(subChannels.ToArray()); if (NotifyChannelOfSubscriptions) { NotifyUpdate?.Invoke(sub); } } }
/// <summary> /// Receives the response from the service. /// </summary> /// <param name="args"></param> private void HandleResponse(CommandRecievedEventArgs args) { try { switch (args.CommandId) { case (int)CommandEnum.GetConfigCommand: ParseConfigResponse(args); break; case (int)CommandEnum.CloseDirectoryHandlerCommand: CloseHandler(args); break; } NotifyUpdate?.Invoke(); } catch (Exception ex) { Console.WriteLine(ex); } }