View
A page from this resource's client files, shown on one player's client: it displays what the resource sends and offers the actions the resource declared. The resource decides everything; the page has no access to the game or the network. The page's script gets darqlinemp: on(topic, function(data, revision)) receives each snapshot; action(name, fields) sends a flat object of booleans, numbers and strings (JSON up to 4 KiB; a burst of 20, then 10 per second); setInputRegions(rects) sets the {x, y, width, height} pixel rectangles that capture the mouse in regions mode (up to 32; a burst of 60 calls, then 60 per second); revision holds the last snapshot's revision. Calls beyond these limits are dropped. onTheme(function(theme)) receives the built-in UI's look from the client, immediately if the page already has it and on each change: font, font_size, opacity, glow and the color_* fields of dlmp.ui_theme. Web storage lasts as long as the view. A login view (Pending:open_view) also has submitAuth(token), which sends the token an auth site gave it to the game server (up to 1024 bytes; a burst of 3, then one every two seconds).
View:id
Returns id integer
View:player
The view's player; nil for a login view while its connection is still pending (Pending:open_view).
Returns player Player|nil
View:is_open
Whether the view is still on the player's screen.
Returns open boolean
View:send
Sends the page a snapshot of topic: data as JSON (sorted keys; an empty table becomes []), up to 16 KiB. The page receives the latest complete snapshot of each topic, including snapshots sent before it loaded. revision, if given, becomes the view's revision; it must not be lower than the current one. From then on an action is accepted only at that revision, so an action from a page that has not yet seen the change is rejected. A snapshot is sent whole or not at all: it fails when the queue is full.
Parameters
topicstring— [a-z0-9_], 1..31 bytesdataany— Plain data: nil, booleans, finite numbers, UTF-8 strings, lists from 1 without holes and string-keyed tables, 32 levels deep at most.revision(optional)integer
Returns ok boolean|nil, err string|nil
View:close
Closes the view; its callbacks are never called after that.
Returns ok boolean|nil, err string|nil
