private IncomingNotification ParseMessage(string notificationString) { var result = new IncomingNotification(); var notificationData = GetNotificationData <NotificationData>(notificationString); var data = JsonConvert.DeserializeObject <IncomingNotification>(notificationData.Data); switch (data?.Type) { case NotificationType.SPLIT_UPDATE: result = JsonConvert.DeserializeObject <SplitChangeNotifiaction>(notificationData.Data); break; case NotificationType.SPLIT_KILL: result = JsonConvert.DeserializeObject <SplitKillNotification>(notificationData.Data); break; case NotificationType.SEGMENT_UPDATE: result = JsonConvert.DeserializeObject <SegmentChangeNotification>(notificationData.Data); break; default: return(null); } result.Channel = notificationData.Channel; return(result); }
private void ProcessEventControl(IncomingNotification notification) { var controlEvent = (ControlNotification)notification; switch (controlEvent.ControlType) { case ControlType.STREAMING_PAUSED: _telemetryRuntimeProducer.RecordStreamingEvent(new StreamingEvent(EventTypeEnum.StreamingStatus, (int)StreamingStatusEnum.Paused)); DispatchActionEvent(SSEClientActions.SUBSYSTEM_DOWN); break; case ControlType.STREAMING_RESUMED: lock (_eventOccupancyLock) { _telemetryRuntimeProducer.RecordStreamingEvent(new StreamingEvent(EventTypeEnum.StreamingStatus, (int)StreamingStatusEnum.Enabled)); if (_publisherAvailable) { DispatchActionEvent(SSEClientActions.SUBSYSTEM_READY); } } break; case ControlType.STREAMING_DISABLED: _telemetryRuntimeProducer.RecordStreamingEvent(new StreamingEvent(EventTypeEnum.StreamingStatus, (int)StreamingStatusEnum.Disabled)); DispatchActionEvent(SSEClientActions.SUBSYSTEM_OFF); break; default: _log.Error($"Incorrect control type. {controlEvent.ControlType}"); break; } }
public void Proccess(IncomingNotification notification) { try { switch (notification.Type) { case NotificationType.SPLIT_UPDATE: var scn = (SplitChangeNotifiaction)notification; _splitsWorker.AddToQueue(scn.ChangeNumber); break; case NotificationType.SPLIT_KILL: var skn = (SplitKillNotification)notification; _splitsWorker.KillSplit(skn.ChangeNumber, skn.SplitName, skn.DefaultTreatment); _splitsWorker.AddToQueue(skn.ChangeNumber); break; case NotificationType.SEGMENT_UPDATE: var sc = (SegmentChangeNotification)notification; _segmentsWorker.AddToQueue(sc.ChangeNumber, sc.SegmentName); break; default: _log.Debug($"Incorrect Event type: {notification}"); break; } } catch (Exception ex) { _log.Error($"Processor: {ex.Message}"); } }
private void ProcessEventControl(IncomingNotification notification) { var controlEvent = (ControlNotification)notification; switch (controlEvent.ControlType) { case ControlType.STREAMING_PAUSED: DispatchOccupancyEvent(publisherAvailable: false); break; case ControlType.STREAMING_RESUMED: if (IsPublisherAvailable()) { DispatchOccupancyEvent(publisherAvailable: true); } break; case ControlType.STREAMING_DISABLED: DispatchPushShutdown(); break; default: _log.Error($"Incorrect control type. {controlEvent.ControlType}"); break; } }
public void HandleIncomingEvent(IncomingNotification notification) { if (notification.Type == NotificationType.CONTROL) { ProcessEventControl(notification); } else if (notification.Type == NotificationType.OCCUPANCY && notification.Channel == Constans.PushControlPri) { ProcessEventOccupancy(notification); } }
private void ProcessEventOccupancy(IncomingNotification notification) { var occupancyEvent = (OccupancyNotification)notification; if (occupancyEvent.Metrics.Publishers <= 0 && IsPublisherAvailable()) { UpdatePublisherAvailable(publisherAvailable: false); DispatchOccupancyEvent(false); } else if (occupancyEvent.Metrics.Publishers >= 1 && !IsPublisherAvailable()) { UpdatePublisherAvailable(publisherAvailable: true); DispatchOccupancyEvent(true); } }
public void HandleIncomingEvent(IncomingNotification notification) { switch (notification.Type) { case NotificationType.CONTROL: ProcessEventControl(notification); break; case NotificationType.OCCUPANCY: ProcessEventOccupancy(notification); break; default: _log.Error($"Incorrect notification type: {notification.Type}"); break; } }
private void ProcessEventOccupancy(IncomingNotification notification) { lock (_eventOccupancyLock) { var occupancyEvent = (OccupancyNotification)notification; UpdatePublishers(occupancyEvent.Channel, occupancyEvent.Metrics.Publishers); if (!ArePublishersAvailable() && _publisherAvailable) { _publisherAvailable = false; DispatchActionEvent(SSEClientActions.SUBSYSTEM_DOWN); } else if (ArePublishersAvailable() && !_publisherAvailable) { _publisherAvailable = true; DispatchActionEvent(SSEClientActions.SUBSYSTEM_READY); } } }
public EventReceivedEventArgs(IncomingNotification incomingNotification) { Event = incomingNotification; }
private void DispatchEvent(IncomingNotification incomingNotification) { _log.Debug($"DispatchEvent: {incomingNotification}"); OnEvent(new EventReceivedEventArgs(incomingNotification)); }
private void DispatchEvent(IncomingNotification incomingNotification) { _log.Debug($"DispatchEvent: {incomingNotification}"); EventReceived?.Invoke(this, new EventReceivedEventArgs(incomingNotification)); }