Difference between revisions of "WebSocket Module"

From BaseX Documentation
Jump to navigation Jump to search
Line 1: Line 1:
This [[Module Library|XQuery Module]] contains functions for accessing specific WebSocket-Functions and setting Attributes on a WebSocket-Connection. This module is mainly useful in the context of [[WebSockets]].
+
This [[Module Library|XQuery Module]] contains functions for accessing specific WebSocket functions and setting attributes on a WebSocket connection. This module is mainly useful in the context of [[WebSockets]].
  
 
=Conventions=
 
=Conventions=
Line 6: Line 6:
 
* All functions and errors are assigned to the <code><nowiki>http://basex.org/modules/websocket</nowiki></code> namespace. The module must be imported in the query prolog:
 
* All functions and errors are assigned to the <code><nowiki>http://basex.org/modules/websocket</nowiki></code> namespace. The module must be imported in the query prolog:
 
<pre class="brush:xquery">
 
<pre class="brush:xquery">
import module namespace session = "http://basex.org/modules/websocket";
+
import module namespace websocket = "http://basex.org/modules/websocket";
 
...
 
...
 
</pre>
 
</pre>
Line 19: Line 19:
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|Broadcasts <code>message</code> which may be of type xs:string, xs:base64Binary, or xs:hexBinary to all connected Members exept to the caller.  
+
|Broadcasts <code>message</code> which may be of type xs:string, xs:base64Binary, or xs:hexBinary to all connected members except to the caller.  
 
|}
 
|}
  
Line 29: Line 29:
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|Returns the ID of the current Websocket Connetion.
+
|Returns the ID of the current WebSocket connection.
 
|}
 
|}
  
Line 39: Line 39:
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|Returns the Websocket Attribute with the key <code>$key</code>. If the <code>$id</code> Parameter is set, it returns the Attribute of a Specific User with the ID <code>$id</code>
+
|Returns the WebSocket attribute with the key <code>$key</code>. If the <code>$id</code> parameter is set, it returns the attribute of a specific User with the ID <code>$id</code>
 
|}
 
|}
  
Line 49: Line 49:
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|Sets a Websocket Attribute with the key <code>$key</code> and the value $value. If the <code>$id</code> Parameter is set, the Attribute of a specific User with the ID <code>$id</code> is set.
+
|Sets a WebSocket attribute with the key <code>$key</code> and the value <code>$value</code>. If the <code>$id</code> parameter is set, the attribute of a specific user with the ID <code>$id</code> is set.
 
|}
 
|}
  
Line 59: Line 59:
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|Removes a Session Attribute from the current WebsocketClient. If the <code>$id</code> Parameter is set, the Attribute of a specific User with the ID <code>$id</code> will be deleted.
+
|Removes a session attribute from the current WebSocketClient. If the <code>$id</code> parameter is set, the attribute of a specific user with the ID <code>$id</code> will be deleted.
 
|}
 
|}
  
Line 69: Line 69:
 
|-
 
|-
 
| '''Summary'''
 
| '''Summary'''
|Returns the Path of the current WebsocketClient. If the <code>$id</code> Parameter is set, the Path of a specific User with the ID <code>$id</code> will be returned.
+
|Returns the path of the current WebSocketClient. If the <code>$id</code> parameter is set, the path of a specific user with the ID <code>$id</code> will be returned.
 
|}
 
|}

Revision as of 13:51, 4 August 2018

This XQuery Module contains functions for accessing specific WebSocket functions and setting attributes on a WebSocket connection. This module is mainly useful in the context of WebSockets.

Conventions

  • The basex-api package must be included in the classpath. This is always the case if you use one of the complete distributions (zip, exe, war) of BaseX.
  • All functions and errors are assigned to the http://basex.org/modules/websocket namespace. The module must be imported in the query prolog:
import module namespace websocket = "http://basex.org/modules/websocket";
...

Functions

websocket:broadcast

Signatures websocket:broadcast($message as xs:anyAtomicType) as empty-sequence()
Summary Broadcasts message which may be of type xs:string, xs:base64Binary, or xs:hexBinary to all connected members except to the caller.

websocket:id

Signatures websocket:id() as xs:string
Summary Returns the ID of the current WebSocket connection.

websocket:get

Signatures websocket:get($key as xs:string) as xs:string
Summary Returns the WebSocket attribute with the key $key. If the $id parameter is set, it returns the attribute of a specific User with the ID $id

websocket:set

Signatures websocket:set($key as xs:string, $value as xs:string) as empty-sequence()
Summary Sets a WebSocket attribute with the key $key and the value $value. If the $id parameter is set, the attribute of a specific user with the ID $id is set.

websocket:delete

Signatures websocket:delete($key as xs:string) as empty-sequence()
Summary Removes a session attribute from the current WebSocketClient. If the $id parameter is set, the attribute of a specific user with the ID $id will be deleted.

websocket:path

Signatures websocket:path() as xs:string
Summary Returns the path of the current WebSocketClient. If the $id parameter is set, the path of a specific user with the ID $id will be returned.