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.
State metadata
This data can be used to carry data around through the execution path.
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
Close this state object
Note: You should never really have to use this method, it is only documented for informational purposes.
This will trigger the same thing as distribute
, but will
return the response value set on the state and the
events to be returned directly to the actor this state refers
to.
Distribute both events and archivist operations currently stacked on this state object.
Distribute all events currently stacked on this state object.
If you wish to also distribute archivist mutations stacked
on this state, please have a look at the distribute
method
instead.
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.
Parse a list of actorIds, and verify who is online
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