internal static void RostManager_OnRosterItem(object sender, jabber.protocol.iq.Item ri) { UpdatePlayers = true; if (!AllPlayers.ContainsKey(ri.JID.User)) { ChatPlayerItem player = new ChatPlayerItem(); player.Id = ri.JID.User; player.Group = "Online"; using (XmlReader reader = XmlReader.Create(new StringReader(ri.OuterXml))) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "group": reader.Read(); string TempGroup = reader.Value; if (TempGroup != "**Default") { player.Group = TempGroup; } break; } } } } player.Username = ri.Nickname; bool PlayerPresence = PresManager.IsAvailable(ri.JID); AllPlayers.Add(ri.JID.User, player); } }
// Public method for callers to get a new contact added to the Roster // Note that we do not add it to our internal roster, the server will send a roster item push public void Add(string jid, string nickname, string[] groups) { // Add the contact to our roster jabber.protocol.iq.RosterIQ riq = new jabber.protocol.iq.RosterIQ(XmppGlobal.InternalClient.Document); riq.Type = jabber.protocol.client.IQType.set; jabber.protocol.iq.Roster r = (jabber.protocol.iq.Roster)riq.Query; jabber.protocol.iq.Item i = r.AddItem(); i.JID = new jabber.JID(jid); foreach (string g in groups) { i.AddGroup(g); } if (!string.IsNullOrEmpty(nickname)) { i.Nickname = nickname; } XmppGlobal.InternalClient.Write(riq); // Subscribe to the contact's presence jabber.protocol.client.Presence p = new jabber.protocol.client.Presence(XmppGlobal.InternalClient.Document); p.Type = jabber.protocol.client.PresenceType.subscribe; p.To = new jabber.JID(jid); XmppGlobal.InternalClient.Write(p); }
void k_OnRosterItem(object sender, jabber.protocol.iq.Item ri) { if (users.ContainsKey(ri.JID.User)) { if (ri.Subscription == jabber.protocol.iq.Subscription.remove) { users[ri.JID.User].status = null; if (UserChanged != null) { UserChanged(users[ri.JID.User]); } users.Remove(ri.JID.User); } else { User us = users[ri.JID.User]; us.Nickname = ri.Nickname; us.Group = ri.GetGroups().First().GroupName; us.item = ri; } } else { User us = new User(ri.JID.User, ri.Nickname, ri.GetGroups().First().GroupName, "", ri); users.Add(ri.JID.User, us); } }
public LolChatUser(string jid, string nickname, string @group, string status, jabber.protocol.iq.Item item) { Item = item; Jid = jid; _nickname = nickname; _group = @group; _status = status; }
public User(string JID, string Nickname, string Group, string status, jabber.protocol.iq.Item _item) { item = _item; _JID = JID; _Nickname = Nickname; _Group = Group; _status = status; }
internal static void RostManager_OnRosterItem(object sender, jabber.protocol.iq.Item ri) { UpdatePlayers = true; if (!AllPlayers.ContainsKey(ri.JID.User)) { ChatPlayerItem player = new ChatPlayerItem(); player.Id = ri.JID.User; player.Username = ri.Nickname; bool PlayerPresence = PresManager.IsAvailable(ri.JID); AllPlayers.Add(ri.JID.User, player); } }
private void GotRosterItemHandler(object sender, jabber.protocol.iq.Item ri) { try { // See if we already have this Item in our collection RosterItem item; roster_items.TryGetValue(ri.JID, out item); // If it's new, add it to our roster and raise the GotRosterItem event if (item == null) { item = new RosterItem(ri.JID); roster_items.Add(ri.JID, item); OnGotRosterItem(new RosterItemEventArgs(item, ri)); } else { // If it's a remove roster update, remove the RosterItem as raise the RosterItemRemoved event if (ri.Subscription == jabber.protocol.iq.Subscription.remove) { roster_items.Remove(item.Jid); OnRosterItemRemoved(new RosterItemEventArgs(item, ri)); } else { // If it's an update, send it to the existing RosterItem, which will handle raising events item.GotUpdatedRosterItem(ri); } } // If the server sent us a "set" (update) roster item, we are supposed to acknowledge it with a "result" if ((ri.ParentNode.ParentNode as XmlElement).GetAttribute("type") == "set") { jabber.protocol.client.IQ result = (jabber.protocol.client.IQ)ri.ParentNode.ParentNode; result.Type = jabber.protocol.client.IQType.result; result.Swap(); XmppGlobal.InternalClient.Write(result); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public RosterItemEventArgs(RosterItem ri, jabber.protocol.iq.Item item) { this.roster_item = ri; this.item = item; }
internal void GotUpdatedRosterItem(jabber.protocol.iq.Item item) { OnRosterItemChanged(new RosterItemEventArgs(this, item)); }