MCPcopy Create free account
hub / github.com/BaseXdb/basex / emit

Method emit

basex-api/src/test/java/org/basex/http/ws/WsPoolTest.java:56–72  ·  view source on GitHub ↗

ws:emit($msg) sends a message to all connected clients (including the sender). @throws Exception exception

()

Source from the content-addressed store, hash-verified

54 * @throws Exception exception
55 */
56 @Test public void emit() throws Exception {
57 register(
58 "declare %ws:message('/p', '{$m}') function m:msg($m) { ws:emit('all:' || $m) };");
59
60 final Listener la = new Listener();
61 final Listener lb = new Listener();
62 final java.net.http.WebSocket wsa = connect("/p", la);
63 final java.net.http.WebSocket wsb = connect("/p", lb);
64 try {
65 wsa.sendText("hi", true).get(5, TimeUnit.SECONDS);
66 assertEquals("all:hi", la.pollText());
67 assertEquals("all:hi", lb.pollText());
68 } finally {
69 close(wsa);
70 close(wsb);
71 }
72 }
73
74 /**
75 * {@code ws:broadcast($msg)} sends to all clients except the sender.

Callers

nothing calls this directly

Calls 6

pollTextMethod · 0.95
assertEqualsMethod · 0.80
getMethod · 0.65
closeMethod · 0.65
registerMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected