Difference between revisions of "WebSocket Module"
Jump to navigation
Jump to search
Line 30: | Line 30: | ||
| '''Summary''' | | '''Summary''' | ||
|Returns the ID of the current WebSocket connection. | |Returns the ID of the current WebSocket connection. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|} | |} | ||
Line 71: | Line 41: | ||
|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. | ||
|} | |} | ||
+ | |||
+ | =Usage Tips= | ||
+ | * <code>websocket:id</code> returns your current session id. You can use all [[Session Module]] and [[Sessions Module]] functions within the websocket context. |
Revision as of 15:27, 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.
Contents
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: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.
|
Usage Tips
websocket:id
returns your current session id. You can use all Session Module and Sessions Module functions within the websocket context.