Session Meta Events and Procedures¶
Session Meta Events and Procedures is a feature from the WAMP Advanced Profile. The specification can be found here.
WAMP enables the monitoring of when sessions join a realm on the router or when they leave it via session metaevents.
It also allows retrieving information about currently connected sessions via session metaprocedures.
Meta-events are created by the router itself. This means that the events as well as the data received when calling a meta-procedure can be accorded the same trust level as the router.
The set of metaevents covers the lifecycle of a session. A client can subscribe to the following session meta events:
wamp.session.on_join: Is fired when a session joins a realm on the router.
wamp.session.on_leave: Is fired when a session leaves a realm on the router or is disconnected.
The WAMP session meta events are dispatched by the router to the same realm as the WAMP session which triggered the event.
Important: To receive and process these events, your component will need to have subscribe permission on the respective topic.
It is possible to actively retrieve information about sessions via the following procedures.
Information on Sessions¶
You can get the count of currently attached sessions via
wamp.session.count: Returns the number of sessions currently attached to the realm.
You can retrieve session IDs via
wamp.session.list: Returns an object with a lists of the session IDs for all sessions currently attached to the realm
Example code for retrieving the list of current session IDs:
Using a session ID, information about a specific session can be retrieved using:
wamp.session.get: Returns data about the session itself: the realm, authentication provider, ID, role and method, as well as about the transport used.
Example code for getting data about a session:
session.call("wamp.session.get", ).then(session.log, session.log)
Killing a Session¶
You can forcibly disconnect a session using:
wamp.session.kill: Disconnects the session, giving a provided reason and message as closing details.
Example code for killing a session: