user1818994
user1818994

Reputation: 11

Send an xmpp message to all connected clients/resources

How can I send one XMPP message to all connected clients/resources using a Python libraries for example:

xmpppy, jabber.py, jabberbot. Any other commandline solution is well.

So far I've only been able to send an echo or a single message to only one client.

The purpose is to send a message to all resources/clients connected, not grouped. This might be triggered by a command but is not 'really' necessary.

Thank you.

Upvotes: 1

Views: 2049

Answers (2)

Muhammad Soliman
Muhammad Soliman

Reputation: 23756

I think If you set the same priorities for all connected resources, It would work but I did not try actually.

However in ejabberd there is a module named Mssage Carbon which do this for you, this feature or property is also available in open fire under the name of "route.all-resource".

Hint: If Message carbons used, XMPP client library should suport this too for making it working.

Upvotes: 1

Alex
Alex

Reputation: 4136

I cannot give you a specific python example, but I explain how the logic works.

When you send a message to a bare Jid then it depends on the server software or configuration how its routed. Some servers send the message to the "most available resource", and some servers send it to all resources. E.g. Google Talk sends it to all resources.

If you control the server software and it allows you to route messages to a bare Jid to all connected resources then this would be the easiest way.

When your code must work on any server then you should collect all available resources of your contacts. You get them with the presence, most libraries have a callback for this. Then you can send out the messages to full Jids (with resources) in a loop.

Upvotes: 1

Related Questions