Rui::Remote::Session - passive mediator between server and widgets
There is a session for each association between a user and a running application instance. The session is used by the server to post client events to server widgets, and to get any messages they may wish to send to the client. Server widgets use the session for passing messages to the client, and listening to client events. It is a passive mediator between them, and knows nothing about the server object or the server widgets. The session lifecycle is handled by a session manager.
There are 2 message types that can be received from the client via the
server object: boot and event. Boot creates a new application, event
post an event from the client to some server widget. Posting a Close
event for the main window destroys the session and the application.
Server side widgets register/deregister as listeners to client-side
events with setClientListener($id, $listener)
and
removeClientListener($id)
. The method
handleClientEvent(%eventParams)
will be called on the listener when a
client-side event is posted. The key used to connect server widgets with
client-side events is the window or widget id.
Messages to the client are send from server widgets to the client using
addWidget/WindowCommand
. The server flushes the messages using
flushBuffer()
, and sends them to the client.
Because there is exactly one session for each running application instance, server widgets also use it to get/set their application object, and to get the next available window and widget ids for the session.