Hi, I'm just hijacking Maximilian's email here to post the following test I wanted to do for experimenting with BaseX and Websockets. I wrote the code at [1] with the intent to open a RESTXQ entrypoint that receives a JSON via POST and the broadcastst it to all connecte WS clients. I might be using ws:broadcast or the naive version as shown but still I get the following error [2] as return to my HTTP POST and, ca va sans dire, nothing on the websocket. What am I doing wrong?
BTW, even if not stated in the path annotation, an extra /ws needs to be prefixed to the url used for JS' WebSocket constructor. Personally I'd prefer to keep things explicit and put it in the annotation too.
Thanks for your support and thanks Maximilian for the lift.
[1] module namespace dp = 'urn:nubisware:datarouter';
import module namespace ws = 'http://basex.org/modules/ws';
declare %rest:path('/dataprovider') %rest:POST("{$data}") %output:method('json') function dp:route($data as node()) { ws:send(json:serialize($data), ws:ids()[. != ws:id()]) };
declare %ws:connect('/dataprovider') function dp:connect() as empty-sequence() { () };
declare %ws:close('/dataprovider') function dp:close() as empty-sequence() { () };
[2] Stopped at /home/lettere/tmp/basex/webapp/dataprovider/dataprovider.xqm, 11/53: [basex:ws] WebSocket connection required.
On 18/10/18 18:33, Christian Grün wrote:
Sir, doing our best ;)
We believe that BaseX 9.1 pretty soon (until end of October).
For everyone who is interested in giving us some feedback on the new WebSocket feature… Thank you in advance! 90% of the documentation is finalized:
http://docs.basex.org/wiki/WebSockets
Best, Christian