Jump to navigation Jump to search
1,724 bytes added ,  16:55, 1 February 2019
no edit summary
| '''Summary'''
|Emits a <code>$message</code> to all connected clients. Invocations of this function are equivalent to <code>ws:send($message, ws:ids())</code>. See [[#ws:send|ws:send]] for more details on the message handling.
{{Mark|Introduced with 9.2:}}
{| width='100%'
| width='120' | '''Signatures'''
|{{Func|ws:eval|$query as xs:anyAtomicItem|xs:string}}<br />{{Func|ws:eval|$query as xs:anyAtomicItem, $bindings as map(*)?|xs:string}}<br />{{Func|ws:eval|$query as xs:anyAtomicItem, $bindings as map(*)?, $options as map(*)?|xs:string}}<br />
| '''Summary'''
|Schedules the evaluation of the supplied {{Code|$query}} and returns the result to the calling WebSocket client. The query can be a URI or a string, and variables and context items can be declared via {{Code|$bindings}} (see {{Functions|XQuery|xquery:eval}} for more details). The following {{Code|$options}} can be supplied:
* {{Code|base-uri}}: sets the [ base-uri property] for the query. This URI will be used when resolving relative URIs, such as with {{Code|fn:doc}}.
* {{Code|id}}: sets a custom job id. The id must not start with the standard <code>job</code> prefix, and it can only be assigned if no job with the same name exists.
Query scheduling is recommendable if the immediate query execution might be too time consuming and lead to a timeout.
| '''Errors'''
|{{Error|overflow|#Errors}} Query execution is rejected, because too many jobs are queued or being executed. <br/>{{Error|id|#Errors}} The specified id is invalid or has already been assigned.
| '''Examples'''
* Cache query result. The returned id can be used to pick up the result with [[#jobs:result|jobs:result]]:
<pre class='brush:xquery'>
%ws:message('/tasks', '{$message}')
function local:message($message) {
ws:eval('Your message has been processed.')
;Version 9.2
* Added: [[#ws:eval|ws:eval]]
This module was introduced with Version 9.1.
Bureaucrats, editor, reviewer, Administrators


Navigation menu