Example #1
0
        private void ProcessRosterIq(Iq iq)
        {
            if (iq.Type == IqType.Get)
            {
                // Send the roster
                // All logged in items for EMRALD are in a roster given for all clients - this may change later
                iq.SwitchDirection();
                iq.Type = IqType.Result;

                //The roster will always include all the connections this may change in the future
                foreach (var con in Global.ServerConnections)
                {
                    var ri = new Matrix.Xmpp.Roster.RosterItem
                    {
                        Jid          = con.Key,
                        Name         = con.Value.User,
                        Subscription = Matrix.Xmpp.Roster.Subscription.Both
                    };

                    ri.AddGroup("EMRALD");
                    ri.AddGroup(con.Value.Resource);
                    iq.Query.Add(ri);
                }

                Send(iq);
            }
            else //if (iq.Type == IqType.Set)
            {
                //For EMRALD items are added to a master roster for everyone to access so no need to set roster items - this may change later
                // TODO, send an error here for

                //if(iq.Query.FirstElement is RosterItem)
                //{
                //  var item = iq.Query.FirstElement as RosterItem;
                //  _roster.Add(item);
                //}
            }
        }