/// <summary> /// Send message to network. /// </summary> /// <param name="messageDeliveryListenerCreator"></param> protected async void SendMessage(MessageDeliveryListenerHandler messageDeliveryListenerCreator) { try { IsNewMessageEnabled = false; IsEditableEnabled = false; MessageStatus = MessageDeliveryStatus.Initial; await Send(); IsNewMessageEnabled = true; MessageStatus = MessageDeliveryStatus.DeliveredToNetwork; MessageDeliveryListener listener = messageDeliveryListenerCreator.Invoke(); if (listener != null) { NotificationManager.Instance.AddListener(listener); listener.StatusChangedEvent += StatusChangedEvent; listener.ListenForMessageDelivered(); } } catch (Exception ex) { MessageStatus = MessageDeliveryStatus.Error; HandleException(ex); IsNewMessageEnabled = true; IsEditableEnabled = true; } }
/// <summary> /// add listener for wait return status /// </summary> /// <param name="listener"></param> public void AddListener(MessageDeliveryListener listener) { Argument.ExpectNotNull(() => listener); listener.StatusChangedEvent += StatusChangedEvent; _listeners.Add(listener); }