Not logged in. · Lost password · Register
Forum: MatriX and XmppDotNet RSS
Avatar
roymanish1982 #1
Member since Mar 2011 · 20 posts
Group memberships: Members
Show profile · Link to this post
Subject: Query Related To Presence Stanza
I have a Query Related to Presence Stanzas.
In http://xmpp.org/rfcs/rfc6121.html#presence-initial-outbound under
Server Processing of Outbound Initial Presence section it shows

<presence from='juliet@example.com/balcony'
              to='romeo@example.net'/>

But when i dubug the Stanza in my server i am getting

<presence xmlns="jabber:client">
  <show>chat</show>
  <status>Available</status>
  <priority>10</priority>
</presence>

"From" is Missing . How to assign the " From " in the Stanza . i am using
  xmppClient.SendPresence(Matrix.Xmpp.Show.chat, "Available", 10);

to send the Prenence to the Server.

Alex can u pls Guide me.
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
You don't need the from when you send it from a client.

Alex
Avatar
roymanish1982 #3
Member since Mar 2011 · 20 posts
Group memberships: Members
Show profile · Link to this post
yes ,

so i did

  Presence p = new Presence();
                p.From = txtUsername.Text;
                p.Show = Matrix.Xmpp.Show.chat;
                p.Status = "Available";
                p.Priority = 10;

xmppClient.Send(p);

And in Server i did

if((e.Stanza as Presence).From != null)
                {

                    // route presences here and handle all subscription stuff

                    ProcessPresence(e.Stanza as Presence);
                   
                }

 private void ProcessPresence(Presence presence)
        {
            foreach(var item in Form1.collection)
            {
                if(item.Key != presence.From)
                {
                    Socket s = item.Value;

                    Presence p = new Presence()
                    {
                        To = item.Key,
                        From = presence.From,
                        Status = presence.Status,
                        Show = presence.Show,
                    };

                    Send(p.ToString(false), s);
                }
            }
        }

is this the Right Way for Presence.
Avatar
roymanish1982 #4
Member since Mar 2011 · 20 posts
Group memberships: Members
Show profile · Link to this post
In reply to post #2
You don't need the from when you send it from a client.
then how server is going to identify whose presence has been updated.
Avatar
Alex #5
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
the server knows on which stream and socket this stanza was received. Because you authenticated and binded your resource before sending this stanza the server has all required information.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters: