private void OnMessagingEvent_MessageState(Client client, BroadcastParams broadcastParams, MessagingEventParams messagingEventParams) { MessagingEventParams.StateParams stateParams = null; try { stateParams = messagingEventParams.ParametersAs <MessagingEventParams.StateParams>(); } catch (Exception exc) { mLogger.LogWarning(exc, "Failed to parse StateParams"); return; } MessageStateChangeHandler(messagingEventParams, stateParams); }
internal void MessageStateChangeHandler(MessagingEventParams eventParams, MessagingEventParams.StateParams stateParams) { Message message = new Message() { Body = stateParams.Body, Context = stateParams.Context, Direction = stateParams.Direction, From = stateParams.FromNumber, ID = stateParams.MessageID, Media = stateParams.Media, Reason = stateParams.Reason, Segments = stateParams.Segments, State = stateParams.MessageState, Tags = stateParams.Tags, To = stateParams.ToNumber, }; OnMessageStateChange?.Invoke(this, message, eventParams, stateParams); switch (stateParams.MessageState) { case MessageState.queued: OnMessageQueued?.Invoke(this, message, eventParams, stateParams); break; case MessageState.initiated: OnInitiated?.Invoke(this, message, eventParams, stateParams); break; case MessageState.sent: OnMessageSent?.Invoke(this, message, eventParams, stateParams); break; case MessageState.delivered: OnMessageDelivered?.Invoke(this, message, eventParams, stateParams); break; case MessageState.undelivered: OnMessageUndelivered?.Invoke(this, message, eventParams, stateParams); break; case MessageState.failed: OnMessageFailed?.Invoke(this, message, eventParams, stateParams); break; } }