voryx / Thruway

PHP Client and Router Library for Autobahn and WAMP (Web Application Messaging Protocol) for Real-Time Application Messaging
MIT License
676 stars 117 forks source link

Question, is there a way to monitor subscription channels in order to create a presence system #361

Open Ethorsen opened 2 years ago

Ethorsen commented 2 years ago

Hi guys,

I have trusted clients that will handle small chat rooms. It registers a few RPCs for the users to call and publish events on the chat subscription channel.

I'd like to have this worker receive a notification whenever a user subscribe/unsubscribe from the room channel, so it can keep track of who's currently in. A simple presence system.

Is there any way to do this? Any help to push me in the right direction would be appreciated.

Thx

boenrobot commented 2 years ago

It's not properly documented with examples, but there is already a way...

See https://github.com/voryx/Thruway/issues/152#issuecomment-220802404

Though I do like your approach with the meta events... Is that part of the standard? Would be nice if it can be enabled/disabled somehow.

Ethorsen commented 2 years ago

Hey @boenrobot,

Yeah its part of the proto standard, section 14.4.5 Subscription Meta API. I listed the links in the PR. https://wamp-proto.org/_static/gen/wamp_latest.html#subscription-meta-events https://crossbar.io/docs/Subscription-Meta-Events-and-Procedures/?highlight=meta#events

Although my changes only implements the Meta Events section of the API (14.4.5.1). I did not create the procedure calls associated (14.4.5.2)

If @mbonneau ever re-surface and is showing interest in the PR, I could work on fully implementing this API. But I've been using my changes for a few months already without any issue. Its pretty much all I need in my project for now.