/// <summary> /// Handler for null data received from the network. /// Fires a log event if LogNullsEnable is true. /// </summary> protected virtual void OnNullReceived() { if (LogNullsEnable) { OnLog?.BeginInvoke(GetLogForNullReceived(), null, null); } }
/// <summary> /// Handler for an IrisError. /// Fires a log event if LogErrorsEnable is true. /// </summary> /// <param name="error">The IrisError received.</param> protected virtual void OnError(IrisError error) { if (LogErrorsEnable) { OnLog?.BeginInvoke(GetLogForError(error), null, null); } }
/// <summary> /// Handler for invalid data received. /// Fires a log event if LogInvalidDataEnable is true. /// </summary> /// <param name="data">The invalid data received.</param> protected virtual void OnInvalidDataReceived(object data) { if (LogInvalidDataEnable) { OnLog?.BeginInvoke(GetLogForInvalidDataReceived(data), null, null); } }
/// <summary> /// Handler for exceptions coming from the network. /// Fires a OnException event. /// Fires a log event if LogExceptionsEnable is true. /// </summary> /// <param name="ex">The exception that occurred.</param> protected virtual void OnNetworkException(Exception ex) { OnException?.BeginInvoke(ex, null, null); if (LogExceptionsEnable) { OnLog?.BeginInvoke(GetLogForException(ex), null, null); } }
/// <summary> /// Handler for a packet received from the network. /// If the packet is of IrisMessage type, invokes the ContentHandlers subscribed to the reception of the message. /// Fires a log event if LogMessagesEnable is true and the packet is of IrisMessage type. /// </summary> /// <param name="packet">The packet received.</param> protected virtual void OnClientSubmittedPacketReceived(IrisPacket packet) { if (packet is IrisMessage) { var message = packet as IrisMessage; IEnumerable <ContentHandler> handlers = null; if (message.TargetChannel != null) { handlers = _channelsSubscriptions.GetSubscriptions(message.TargetChannel, message.PropagateThroughHierarchy); } else { var broadcastHandlers = new List <ContentHandler>(); broadcastHandlers.AddRange(_broadcastHandlers); handlers = broadcastHandlers; } if (handlers != null) { var ctxHook = new IrisContextHook() { TargetChannel = message.TargetChannel, PublicationDateTime = message.PublicationDateTime }; foreach (var hander in handlers) { hander.BeginInvoke(message.Content, ctxHook, null, null); } } if (LogMessagesEnable) { OnLog?.BeginInvoke(GetLogForMessageReceived(message), null, null); } // No subscription found for this message if (handlers == null) { OnLog?.BeginInvoke(GetLogForError(new IrisError(Id) { Log = $"Unable to find subscriptions for the channel {message.TargetChannel}. [Message]{GetLogForMessageReceived(message)}." }), null, null); } } }