private static void HandleNotifyMessage(string message, IObserver <NotifyMessage> observer) { logger.Instance().Trace("Received notification message", "Message".As(message)); try { var notifyMessage = NotifyMessage.Create(message); observer.OnNext(notifyMessage); } catch (ArgumentException ex) { logger.Instance().Warning(ex, "The received notification message has been discarded.", "Message".As(message)); } }
private async void NotifyMessageReceived(DatagramSocket sender, DatagramSocketMessageReceivedEventArgs args) { var dataReader = args.GetDataReader(); dataReader.InputStreamOptions = InputStreamOptions.Partial; if (dataReader.UnconsumedBufferLength == 0) { await dataReader.LoadAsync(1024); } var message = dataReader.ReadString(dataReader.UnconsumedBufferLength); try { var notifyMessage = NotifyMessage.Create(message); this.notifyMessages.OnNext(notifyMessage); } catch (ArgumentException ex) { logger.Instance().Warning(ex, "The received notification message has been ignored.", "Message".As(message)); } }