$session->connect_client VISUAL,
STATE
This is the JS accessible version of the login which returns a JS string to set up the connection.
Also sends the diffs from STATE to the current state if STATE
is 0 or undefined
.
If STATE
is -1 then no updates are sent as the client is expected to retrieve the complete document via document
.
$api->valid_cookie COOKIE
(Internal only)
Returns the user if the cookie is a valid cookie for this session. See also Zaphod::Session::valid_cookie
$session->new_user CLIENT
Returns CLIENT
as a new User()
JS statement,
used by connect_client
.
$session->disconnect_client CLIENT
Removes the client from the session
$session->users CLIENT,
OFS,
STATE
Returns the (positions of the) other users in the current session as Javascript coded.
Also returns any new actions that happened since STATE
,
if any.
TODO: All of changes
,
users
,
document
and whatnot should be rolled into two structures,
one input and one output structure.
$session->document
Returns a JS statement to assign the document.
TODO: The "current" document should be a text/plain
document that can be retrieved partially to speed up the handling/editing of large documents.
$session->set_name CLIENT,
STATE,
NEWNAME
Sets the name of the current session, permissions provided.
The new name will be broadcast to the other clients. The name change is currently out-of-band with the editor, so there is no undo/redo functionality for it.
$session->js_response RESPONSE,
@code
Returns the statements wrapped as a JS response.
Always prepends a timestamp to the timestamp
JS variable.
TODO: The client could check/maintain the time of the last response itself.
$sesion->actions CLIENT,
STATE,
ACTIONSTRING
Takes a string of actions, reconciles them with the parallel other actions, and returns JS code to update the client positions and to replace the submitted actions. Also returns code to update the client state number.
TODO: Currently knows too much about the underlying session
object.
Separate the functionalities.
$session->encode_js_string STRINGS
Helper method to generate quoted JS strings.
The nonprintable or special characters will be escaped by using backslashes and hexadecimal notation (\xFF
).
TODO: Use a standard (JSON?) method instead of hand-rolling my own.
$session->params2utf8 ARGS
Converts all the arguments from ISO-8859-1 to utf8.