public IQ GetRosterIq(Jid to) { var iq = new IQ(IqType.set); var roster = new Roster(); roster.AddRosterItem(ToRosterItem()); iq.Query = roster; iq.To = to.BareJid; return(iq); }
private IQ GetRoster(XmppStream stream, IQ iq, XmppHandlerContext context) { var answer = new IQ(IqType.result); answer.Id = iq.Id; answer.To = iq.From; var roster = new Roster(); answer.Query = roster; foreach (var item in context.StorageManager.RosterStorage.GetRosterItems(iq.From)) { roster.AddRosterItem(item.ToRosterItem()); } var session = context.SessionManager.GetSession(iq.From); session.RosterRequested = true; session.GetRosterTime = DateTime.UtcNow; return answer; }
private void SendRosterPresences(XmppSession session) { //It's correct! //Get other statuses foreach (var ri in rosterStore.GetRosterItems(session.Jid)) { //"none" -- the user does not have a subscription to the contact's presence information, and the contact does not have a subscription to the user's presence information //"to" -- the user has a subscription to the contact's presence information, but the contact does not have a subscription to the user's presence information //"from" -- the contact has a subscription to the user's presence information, but the user does not have a subscription to the contact's presence information //"both" -- both the user and the contact have subscriptions to each other's presence information if (ri.Subscribtion == SubscriptionType.to || ri.Subscribtion == SubscriptionType.both) { foreach (var contactSession in sessionManager.GetBareJidSessions(ri.Jid)) { if (contactSession.Presence != null) { //Send roster contact presence to newly availible session contactSession.Presence.To = null;//To no one sender.SendTo(session, contactSession.Presence); if (contactSession.GetRosterTime.AddMinutes(1) < DateTime.UtcNow) { //Send roster push var roster = new Roster(); roster.AddRosterItem(rosterStore.GetRosterItem(contactSession.Jid, session.Jid).ToRosterItem()); var iq = new IQ { Type = IqType.set, Namespace = Uri.SERVER, Id = UniqueId.CreateNewId(), To = contactSession.Jid, Query = roster }; sender.SendTo(contactSession, iq); } } } } } var server = new Presence() { Type = PresenceType.available, From = new Jid(session.Jid.Server) }; sender.SendTo(session, server); }
private void AddBuddyGroup(BuddyGroup group) { lock (Groups) { lock (Roster) { BuddyGroup destGroup = group; for (int i = 0; i < Groups.Count; i++) { if (group.GroupName == Groups[i].GroupName) { destGroup = Groups[i]; break; } } foreach (var item in group.Buddies) { destGroup.Buddies.Add(item); Roster.AddRosterItem( new Xmpp.Roster.RosterItem(item.Username, item.Nickname, destGroup.GroupName)); } } } }