Handling Connection Events

The primary mechanism for users to get access to the document is via a persistent connection (vis-à-vis WebSocket) and then send messages to the document. Before messages can be sent, the connection must be authorized by the document and this is done via the @connected keyword.

@connected(who) {
return true;

This code is run when a person connects to the document, and if the return value is true then the connection is established. Not only can they connect, but they also naturally disconnect (either on purpose or due to technical difficulties). The disconnect signal is an informational event only, and is available via the @disconnected keyword

@disconnnected (who) {

In both of these events, the who variable has a type of client which is the user.