* The module will be available if the {{Code|basex-api}} library is found in the classpath. This is the case if you use one of the complete distributions of BaseX (zip, exe, war).
* All functions and errors are assigned to the <code><nowiki>http://basex.org/modules/ws</nowiki></code> namespace, which is statically bound to the {{Code|ws}} prefix.
* As sessions are side-effecting operations, all functions are flagged as ''non-deterministicnondeterministic''. As a result, some query optimizations will be suppressed.
=General Functions=
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:id||() as xs:string}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:ids||() as xs:string*}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:path|( $id as xs:string|) as xs:string}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:close|( $id as xs:string|) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:send|( $message as item(), $ids as xs:string*|) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:broadcast|( $message as xs:anyAtomicType|) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:emit|( $message as xs:anyAtomicType|) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|ws:eval|$query as xs:anyAtomicType|xs:string}}<br /pre>{{Func|ws:eval|( $query as xs:anyAtomicType, $bindings as map(*)?|xs:string}}<br />{{Func|ws :eval|$query as xs:anyAtomicType, $bindings as map= (*)?, $options as map(*)?| := map { }) as xs:string}}<br /pre>
|- valign="top"
| '''Summary'''
|
* Schedule a second query that will notify the client 10 seconds later that a message was processed:
<syntaxhighlight pre lang="'xquery"'>
declare
%ws:message('/tasks', '{$message}')
ws:eval('prof:sleep(10000), "Your message has been processed."')
};
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|ws:get|$id as xs:string, $name as xs:string|item()*}}<br/pre>{{Func|ws:get|( $id as xs:string, $name as xs:string, $default as item()*| := ()) as item()*}}</pre>
|- valign="top"
| '''Summary'''
|Returns the value of an attribute with the specified {{Code|$name}} from for the WebSocket with the specified {{Code|$id}}. If the attribute is unknown, an empty sequence or the optionally specified {{Code|$default}} value will be returned instead.
|- valign="top"
| '''Errors'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:set|( $id as xs:string, $name as xs:string, $value as item()*|) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
|Returns Assigns the specified {{Code|$value}} of to the attribute with the specified {{Code|$name}} from for the WebSocket with the specified {{Mono|$id}}.
|- valign="top"
| '''Errors'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>ws:delete|( $id as xs:string, $name as xs:string|) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
==Example 1==
<syntaxhighlight pre lang="'xquery"'>
import module namespace ws = "http://basex.org/modules/ws";
return ws:broadcast($message)
};
</syntaxhighlightpre>
'''Explanation:'''
==Example 2==
<syntaxhighlight pre lang="'xquery"'>
import module namespace ws = "http://basex.org/modules/ws";
return ws:emit($message)
};
</syntaxhighlightpre>
'''Explanation:'''