/// <summary>
        /// Sends our Presence, the packet is built of Status, Show and Priority
        /// </summary>
        public void SendMyPresence()
        {
            Presence pres = new Presence(m_Show, m_Status, m_Priority);

            // Add client caps when enabled
            if (m_EnableCapabilities)
            {
                if (m_Capabilities.Version == null)
                    UpdateCapsVersion();

                pres.AddChild(m_Capabilities);
            }

            this.Send(pres);
        }
Beispiel #2
0
        /// <summary>
        /// Join a chatroom
        /// </summary>
        /// <param name="room">jid of the room to join</param>
        /// <param name="nickname">nickname to use in the room</param>
        /// <param name="password">password for password protected chat rooms</param>
        /// <param name="disableHistory">true for joining without chat room history</param>
        public void JoinRoom(Jid room, string nickname, string password, bool disableHistory)
        {
            /*
            <presence
                from='[email protected]/pda'
                to='[email protected]/thirdwitch'>
              <x xmlns='http://jabber.org/protocol/muc'>
                <password>cauldron</password>
              </x>
            </presence>

            join room and request no history
            <presence
                from='[email protected]/pda'
                to='[email protected]/thirdwitch'>
              <x xmlns='http://jabber.org/protocol/muc'>
                <history maxchars='0'/>
              </x>
            </presence>
            */

            Jid to = new Jid(room.ToString());
            to.Resource = nickname;

            Presence pres = new Presence();
            pres.To = to;
            Muc x = new Muc();
            if (password != null)
                x.Password = password;

            if (disableHistory)
            {
                History hist = new History();
                hist.MaxCharacters = 0;
                x.History = hist;
            }

            pres.AddChild(x);

            m_connection.Send(pres);
        }
Beispiel #3
0
        public override void SetPresenceStatus(PresenceStatus status,
                                               string message)
        {
            Trace.Call(status, message);

            if (!IsConnected) {
                return;
            }

            switch (status) {
                case PresenceStatus.Online:
                    JabberClient.Show = ShowType.NONE;
                    JabberClient.Priority = Server.Priorities[status];
                    JabberClient.Status = message;
                    break;
                case PresenceStatus.Away:
                    JabberClient.Priority = Server.Priorities[status];
                    JabberClient.Show = ShowType.away;
                    JabberClient.Status = message;
                    break;
            }

            JabberClient.SendMyPresence();

            // send presence update to all MUCs, see XEP-0045:
            // http://xmpp.org/extensions/xep-0045.html#changepres
            foreach (var chat in Chats) {
                if (!(chat is XmppGroupChatModel)) {
                    continue;
                }
                var muc = (XmppGroupChatModel) chat;

                var to = new Jid(muc.ID) {
                    Resource = muc.OwnNickname
                };

                var presence = new Presence() {
                    Show = JabberClient.Show,
                    Status = JabberClient.Status,
                    From = JabberClient.MyJID,
                    To = to
                };

                if (JabberClient.EnableCapabilities) {
                    presence.AddChild(JabberClient.Capabilities);
                }
                JabberClient.Send(presence);
            }

            base.SetPresenceStatus(status, message);
        }