private void OnErrorMessagedReceived(object sender, Message msg) { Console.WriteLine(msg.ToString()); }
private void OnMessage(object sender, Message msg) { Parallel.ForEach(this.observers, o => { try { if (msg.Type == MessageType.chat || msg.Type == MessageType.groupchat) { // TODO: XMPP can send all sorts of messages, gotta filter them out if (msg.Body != null) { o.OnNext( new MessageData( // TODO: should we reply to the bare address all the time? replyTo: msg.Type == MessageType.groupchat ? msg.From.ToJid().Bare : msg.From.ToJid(), senderAddress: msg.From.ToJid(), senderName: msg.Type == MessageType.groupchat ? msg.From.Resource : msg.From.User, // TODO: better way to do this... body: msg.Body, // TODO: is there a better way to check for this? isFromMyself: msg.Type == MessageType.groupchat ? String.Equals(msg.From.Resource, this.config.Name, StringComparison.OrdinalIgnoreCase) : string.Equals(msg.From.Bare, this.config.Jid.Bare), isHistorical: msg.XDelay != null, isPrivate: msg.Type != MessageType.groupchat ) ); } else { // TODO: e.g. subject message Console.Error.WriteLine("Message with null body"); Console.Error.WriteLine(msg.ToString()); } } else { // TODO: need to handle the other types } } catch (Exception e) { // TODO: AgsXmppBackend: Handle observer errors Console.Error.WriteLineAsync(e.ToString()); } }); }