I have made some progress on this... I think the protocol response to the watch is in fact {port}{id}\0 Where {port} is a basex server port to connect in order to receive events and {id} some identifier. The client should connect to the port and send {id}\0. The response is \0. After this the connection will receive events in the form {name}{msg}
I have implemented this in node.js. One difficulty is the very asynchronous nature of node I have tried to recreate something based on the c#https://github.com/BaseXdb/basex-api/blob/master/src/main/c%23/EventExample.csexample in nodehttps://github.com/apb2006/basex-node/blob/master/examples/EventExample.jsallowing for this. It runs fine the first time after the server is started, in subsequent runs the event is never received.
The log from the 1st run is
21:19:01.858 [127.0.0.1:38155] LOGIN admin OK 21:19:01.861 [127.0.0.1:38156] LOGIN test1 OK 21:19:02.003 [127.0.0.1:38155] CREATE EVENT messenger 21:19:02.005 [127.0.0.1:38155] OK 143.0 ms 21:19:02.027 [127.0.0.1:38156] OK 13.41 ms 21:19:02.247 [127.0.0.1:38156] QUERY(0) for $i in 1 to 1000000 where $i=3 return $i OK 219.51 ms 21:19:02.248 [127.0.0.1:38156] QUERY(0) OK 0.5 ms 21:19:02.252 [127.0.0.1:38155] QUERY(0) db:event('messenger', 'Hello World!') OK 230.45 ms 21:19:02.254 [127.0.0.1:38155] QUERY(0) OK 0.76 ms 21:19:02.584 [127.0.0.1:38155] EXEC(0) OK 329.22 ms 21:19:02.943 [127.0.0.1:38156] EXEC(0) OK 694.17 ms 21:19:02.945 [127.0.0.1:38156] OK 0.34 ms 21:19:03.004 [127.0.0.1:38155] DROP EVENT messenger 21:19:03.005 [127.0.0.1:38155] OK 2.18 ms 21:19:03.006 [127.0.0.1:38155] EXIT 21:19:03.011 [127.0.0.1:38155] OK 6.03 ms 21:19:03.012 [127.0.0.1:38155] LOGOUT admin OK 21:19:03.014 [127.0.0.1:38156] EXIT 21:19:03.019 [127.0.0.1:38156] OK 6.57 ms 21:19:03.020 [127.0.0.1:38156] LOGOUT test1 OK The next run gives
19:16.106 [127.0.0.1:38158] LOGIN admin OK 21:19:16.112 [127.0.0.1:38158] CREATE EVENT messenger 21:19:16.115 [127.0.0.1:38158] OK 27.79 ms 21:19:16.151 [127.0.0.1:38159] LOGIN test1 OK 21:19:16.192 [127.0.0.1:38158] QUERY(0) db:event('messenger', 'Hello World!') OK 0.98 ms 21:19:16.200 [127.0.0.1:38158] QUERY(0) OK 7.4 ms 21:19:16.207 [127.0.0.1:38159] OK 0.65 ms 21:19:16.220 [127.0.0.1:38159] QUERY(0) for $i in 1 to 1000000 where $i=3 return $i OK 7.77 ms 21:19:16.231 [127.0.0.1:38159] QUERY(0) OK 4.3 ms 21:19:16.253 [127.0.0.1:38158] EXEC(0) Error: null 21:19:16.732 [127.0.0.1:38159] EXEC(0) OK 459.42 ms 21:19:20.036 [127.0.0.1:38158] LOGOUT admin OK 21:19:20.042 [127.0.0.1:38159] LOGOUT test1 OK
The problem seems to EXEC(0) Error: null Any ideas what the cause might be or how I can debug this further. /Andy
On Thu, May 17, 2012 at 12:04 PM, Andreas Weiler < andreas.weiler@uni-konstanz.de> wrote:
Hi Andy,
- The documentation at http://docs.basex.org/wiki/Server_Protocol shows
nothing in the Server Response column. This seems not to be the case. It looks like a standard BaseX protocol type response is to be expected?
yes you are right, the server response is a standard basex info message.
- The example at
https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/base... shows session2 watching and then executing. Does the server protocol identify "event pushes" in some way. That is when I receive a message how can I tell if is a event or a command response?
the event reponse is send over a separate socket connection.
-- Andreas
Am 17.05.2012 um 12:22 schrieb Andy Bunce:
Hi, I am looking at adding WATCH and UNWATCH to my Node.js BaseX interface and I have a couple of questions before I start.
- The documentation at http://docs.basex.org/wiki/Server_Protocol shows
nothing in the Server Response column. This seems not to be the case. It looks like a standard BaseX protocol type response is to be expected?
- The example at
https://github.com/BaseXdb/basex-examples/blob/master/src/main/java/org/base... session2 watching and then executing. Does the server protocol identify "event pushes" in some way. That is when I receive a message how can I tell if is a event or a command response?
/Andy _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk