What is doable in plugin

Hi,

is it possible to create a “fake” user within a plugin?

Basically I want a user which is displayed as “online” to other users but which has no “physical” client.

E.g.

I would like to register a user with the following id: robot@robot.localhost

He should be displayed as robot in a shared group roster. As soon as a user sends a message to robot, I want to intercept this message, so it’'s never delivered.

What I have accomplished so far with a plugin:

-intercept messenges (broadcast plugin)

-create users (via the usermanager)

What’'s missing is the step of “activating” them, so they appear as online. I tried to create a presence with the presenceManager but this seems not to be enough.

Is it possible to do that? Or am I wasting my time with trying something that’'s simply not doable because of the XMPP nature?

Thanks,

Markus

Markus,

If you’'re willing to use a subdomain such as “robot.localhost”, then that implies that it can be a component. See JEP-0114 for more info. You can make a plugin act as a component easily – see the Broadcast plugin as an example.

To make the component “online”, it would have to send and recieve presence packets correctly. If it sends an available packet each time it logs in to the server, that should be enough.

Regards,

Matt

Hi Matt,

thanks for that. Do you mind giving me a short hint how to send an available packet?

I tried to find similiar actions in the sourcecode but I’'m somehow lost there.

A short tip where to look how to assemble such a packet and which module I should use to send it would be very helpfull.

Thanks,

Markus

Markus,

It should be as simple as:

ComponentManager.sendPacket(new Presence());

Regards,

Matt

I tried it with

ComponentManager.getInstance().addComponent(serviceName, this);

ComponentManager.getInstance().sendPacket(new Presence());

in the initialize method of the component. But there is no visible reaction to this call. It does not appear as “online” in either the admin console nor the clients.

Anything I’'m missing?

Markus,

You would need to listen for presence subscription requests and honor them if you want presence to work. We don’'t currently have a page in the admin console that shows all connected components, but plan to add that for an upcoming release. To test your component, you might just want to send a message to the component and then have the component print it out to stdout, etc.

Regards,

Matt

Hi Matt,

thanks again. It’‘s no problem sending messages to the component. But it’'s not of worth if nobody knows that there is a “robot” listening for messages. I somehow need to make the component visible for the clients. I will dig a little bit through the code, to see how things work.

regards,

Markus

Hi,jocsch,

whether you can send your code to me , I want to know how he works.

thanks.

Hi tangzhen,

I’‘m sorry, there isn’‘t much to show. It’‘s basically the broadcast plugin in which I tried what is possible to do with a component and what not. Ok, and that’‘s not much because it was easy to figure out that it is not possible to register a component as part of a shared group and it’'s also not possible to give a user a subdomain JID.

So all I have is the broadcast plugin. I’'m still hoping that there will be a solution for one ove the mentioned problems, before I proceed further.

Markus