Project

General

Profile

Broadcaster component, how to get the list of connected clients?

Gabriel Rossetti
Added over 4 years ago

Hi all,

I need to send a msg to all my connected users (offline are ignored, no need for persistance), up until now I was using PubSub but because of the issue described here: https://projects.tigase.org/boards/9/topics/3601 I cannot. Since then I decided that maybe PubSub is a bit too much for my needs, I really just need the basic functionality described above. I found the BroadcastToOnline command which is what I want to do, but I want to do this from a Component. I decided to write my own broadcaster component which would receive a msg and send it to all the connected users but I cannot find how to get the connected users list. I saw that SessionManager should be able to give me that but from my component I don't have access to it (as far as I know).

Does someone know how to do that?

Thanks,

Gabriel


Replies (5)

Added by Wojciech Kapcia TigaseTeam over 4 years ago

Gabriel Rossetti wrote:

I found the BroadcastToOnline command which is what I want to do, but I want to do this from a Component.

The question is - why?. What is the use case that requires this to be solved using component?

Added by Gabriel Rossetti over 4 years ago

Because it made sense, a bit like PubSub. The msg is generated from a component, with no human intervention, possibly several times a second, it is sending events/notifications/statuses. I may need some configuration (blacklist some users, etc). The msg source component already does a lot of stuff and I would prefer it just send a msg to another component to deal with it.

(1)
Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam over 4 years ago

One of possible approaches is to use ad-hoc admin commands. There is already a command which broadcasts message to all online users. You can implement own version based on this as example code.

(1)

Added by Gabriel Rossetti over 4 years ago

Artur Hefczyc wrote:

One of possible approaches is to use ad-hoc admin commands. There is already a command which broadcasts message to all online users. You can implement own version based on this as example code.

But those are supposed to be called from a client I thought? Can a component call the ad-hoc admin commands?

(1)

Added by Wojciech Kapcia TigaseTeam over 4 years ago

It's possible - for example HTTP api component does such. It's only a matter of addressing the packet and adding JID of your component to the list of administrators (in order to pass the verification to execute command).

    (1-5/5)