public void SendMessageRoster(Message message) { if (message != null) { RosterMessage request = new RosterMessage(); request.fromJID = message.FromJid; request.toJID = message.ToJid; request.message = this.utilService.MessageEncode(message.MessageBlocks); request.style = message.Style.ToString(); request.type = message.VOType; this.connection.Send(PacketType.ROSTER_MESSAGE, request); } }
private void C_NewRoosterMessage(IMessageSender sender, NewValidMessageEventArgs args) { XMPPClient client = sender as XMPPClient; if (args.MESSAGE is RosterMessage) { RosterMessage msg = args.MESSAGE as RosterMessage; string to = client.getXMPPAccount().getIdAndDomain(); string type = msg.TYPE; if (string.Equals(type, IQMessage.RESULT)) { ChatDBManager.INSTANCE.setAllNotInRoster(client.getXMPPAccount().getIdAndDomain()); } else if (type == null || !string.Equals(type, IQMessage.SET)) { // No roster result or set => return return; } foreach (RosterItem item in msg.ITEMS) { string from = item.JID; string id = ChatTable.generateId(from, to); ChatTable chat = ChatDBManager.INSTANCE.getChat(id); if (chat != null) { chat.subscription = item.SUBSCRIPTION; chat.inRoster = !item.SUBSCRIPTION.Equals("remove"); chat.ask = item.ASK; } else if (!Equals(item.SUBSCRIPTION, "remove")) { chat = new ChatTable() { id = id, chatJabberId = from, userAccountId = to, subscription = item.SUBSCRIPTION, lastActive = DateTime.Now, muted = false, inRoster = true, ask = item.ASK, chatType = ChatType.CHAT }; } else { continue; } switch (chat.subscription) { case "unsubscribe": case "from": case "none": case "pending": case null: chat.presence = Presence.Unavailable; break; default: break; } ChatDBManager.INSTANCE.setChat(chat, false, true); } } }
private void RosterMessageEvent(RosterMessage response) { try { if (response != null) { Message msg = new Message(); MessageStyle ms = new MessageStyle(response.style); msg.CreateTime = response.date; msg.FromJid = response.fromJID; msg.MessageBlocks = this.utilService.MessageDecode(response.message); msg.Style = ms; msg.VOType = response.type; msg.MessageObjectType = MessageActorType.Roster; if (this.IsNotifyFlashing(msg)) { NotifyIconUtil.Instance.SetFlashIcon(FlashIconType.Roster); NotifyIconUtil.Instance.StartFlashing(); this.dataModel.AddMessage((long)((ulong)Jid.GetUid(msg.FromJid)), MessageActorType.Roster, msg); if (this.IsAddMessageBox()) { MessageBoxWindow mbw = this.dataModel.GetMessageBox(); if (mbw == null) { mbw = new MessageBoxWindow(); this.dataModel.SetMessageBox(mbw); } mbw.Refresh(); mbw.Show(); } } else { this.RosterAddMessage(msg); } } } catch (System.Exception ex) { System.Console.WriteLine(ex.ToString()); } }