Archivist instance
When a state is received through a user command, use this archvist instance
to make your data transactions. The state will automatically call distribute
upon a successful user command execution.
Session instance
Broadcast an event to all connected users
Verify the current user's credentials
Clear a given state's timeout
This will do nothing if a timeout is not set on the state
Send an event to the user
Note that the event will be blackholed if an user with a given actorId is not currently connected.
Return an error to the user
This will generally be called in synchronouse user commands to specify that an error has occured, and that no response data is to be expected.
Note that asynchronous user commands as defined in
https://mage.github.io/mage/#using-async-await-node-7-6
do not require you to call state.error
; instead, you can simply
throw an Error. If the Error instance has a code
attribute, the code
will then also be returned as part of the response to the end-user.
Register a session on the user
Reply to the user
This will generally be called in synchronouse user commands to specify what value to return to the end-user.
Note that asynchronous user commands as defined in
https://mage.github.io/mage/#using-async-await-node-7-6
do not require you to call state.respond
; instead, simply return
the data you wish to send to the end-user.
Define a timeout on the state
Once the timeout is reached, the state will automatically report an error to the end-user.
Note that you do not have to call clearTimeout
manually when
receiving a state in a user command; this will be done automatically for you.
Forget the current session for the current user
Actor ID
Depending on how the state object was created, the actor ID may hold different meaning; however, it will in most cases hold the session ID of the user currently executing the user command. This will only apply to users authenticated through the auth module.
{string}
IState