Project

General

Profile

Plugin to process Presence

Razor Ra
Added over 5 years ago

Hi,

Is there a way to process the Presence stanza in plugins?

Right now I am creating plugins which have XMLNS and ELEMENTS.

But for stanza like this

<presence from="juliet@capulet.com/balcony" to="user@tigase-server" type="available"/>

which have no name space and element. How to process this in plugin?

Thanks


Replies (4)

Added by Wojciech Kapcia TigaseTeam over 5 years ago

use following xmlns="jabber:client"

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 5 years ago

All stanzas must have name space attribute. If the name space is missing then the stanza would be rejected/dropped as unknown.

Added by Razor Ra over 5 years ago

I have created a test app using Smack which sends Presence stanza:

<presence id="abcd" to="admin@my-tigase" from="test@my-tigase/Smack"/>

Code:

ConnectionConfiguration config = new ConnectionConfiguration("my-tigase", 5222);
config.setSendPresence(false); // not send <presence> stanza at login

connection = new XMPPConnection(config);
connection.connect();
connection.login("test@my-tigase", "test");

Presence send = new Presence(Presence.Type.available);
send.setPacketID("abcd");
send.setFrom(connection.getUser());
send.setTo("admin@my-tigase");
connection.sendPacket(send);

In tigase Plugin, I am simply trying to get the stanzas whose type is available

@Override
  public void process(
          final Packet packet,
          final XMPPResourceConnection session,
          final NonAuthUserRepository repo,
          final Queue queue,
          final Map settings) throws XMPPException 
{

   System.out.println("Presence Packet: " + packet); 

}

But the stanzas I got here are of type null*, *unavailable and probe:

Presence Packet: from=sess-man@my-tigase, to=sess-man@my-tigase, 
DATA=<presence xmlns="jabber:client" from="test@my-tigase/Smack" id="abcd" to="admin@my-tigase"/>, 
SIZE=98, XMLNS=jabber:client, PRIORITY=PRESENCE, PERMISSION=AUTH, TYPE=null

Why does available stanza types never comes to this plugin?

Thanks

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 5 years ago

null is the "available* stanza you are looking for. The spec says that if the type attribute is missing in presence stanza it means available*. Our default Presence plugin takes care of it. Please have a look at the beginning of the *process() method in our plugin to see how this is done.

    (1-4/4)