Extend presence packets automatically

Hi!

Right now I’m working on a plug in for Spark. It works out so far but now I want to add some information to the presence packets of all clients which us the plug in to identify them. To do this I implemented PacketExtension and PacketExtensionProvider. This also works out when I do the following:

Presence presence= new Presence( Presence.Type.available );
presence.addExtension( new presenceExtention() );
connection.sendPacket( presence);

It’s ok but it would be nice to have the extension added to every presence which is send by my client automatically. I was looking for a Manager or something like that where I can register my extension by I didn’t find any.

Does anybody have an idea how to do this or if this is even possible?

I got a similar problem: is there any way to extend presence packets so SERVER can automatically send them to a certain room users?

I need to introduce a new status, so when I log in a room openfire should send me presence packets containing my custom status for each room user. Any ideas?

In this world (forum) you have to find out your answers alone…

I found mine: every presence packet I send to a room is copied by server 1:1 (with every extension) and sent to every room occupant, even to late joiners.

I found your answer as well: simply extend Presence packets and in the constructor you make

public customPresence(Presence.Type t){

super(t);

addExtension(new presenceExtension());

}

so from now you’ll just have to make:

CustomPresence presence = new CustomPresence(Presence.Type.availaible);

connection.send(presence);

Don’t be mad. I guess the other users have to do other stuff all day long than wainting for a question of you or me but thanks for your answer anyways.

It’s not a bad idea although it’s not 100% what I am looking for. I want to extend every single presence paket which leaves Spark but if the user changes it’s status to e.g. DND by using the GUI my plugin doesn’t notice the change so Spark just sends the “normal” presence paket.

Maybe I could try fetch each status in the list on start up and extend it or even replace it by a modified one.

I’m currently developing server side so I don’t know how to program on spark (maybe we can make a complete application together lol).

If you have spark code you could modify the listener function so it sends your custom packets…as button listeners are already in spark I don’t think you can obtain different behaviours through a plugin…

Thanks for your advice. I took a closer look and found out that it’s possible to implement PresenceListener and at this to the SessionManager by doing something like SparkManager.getSessionManager().addPresenceListener(new PresenceModifier());

It works and I get the new Presence which was set by the user BUT I can’t modify it. Well, I can modify the Presence, but this won’t effect the presence which is send to the server.

Does anybody know how to do that?

Update: I used the wrong Listener. It works when I am using addPacketWriterListener with a filter for Presence Pakets.