### Question:
WSServer implements WebSocketConnectionCallback, Callback<Buffer> { public void start() { final PathHandler pathHandler = Handlers.path(); for (String name : handlers.keySet()) { pathHandler.addPrefixPath(name, handlers.get(name)); } this.server = Undertow.builder().addHttpListener(port, "0.0.0.0", pathHandler).build(); server.start(); if (builder.storage != null) { builder.storage.listen(this); } else if (builder.storageFactory != null) { builder.storageFactory.listen(this); } } WSServer(GraphBuilder p_builder, int p_port); static void attach(GraphBuilder storage, int port); WSServer addHandler(String prefix, HttpHandler httpHandler); void start(); void stop(); @Override void onConnect(WebSocketHttpExchange webSocketHttpExchange, WebSocketChannel webSocketChannel); @Override final void on(final Buffer result);  }### Answer:
@Test public void test() { final Graph graph = new GraphBuilder() .withMemorySize(10000) .build(); graph.connect(new Callback<Boolean>() { @Override public void on(Boolean result) { Node node = graph.newNode(0, 0); node.set("name", Type.STRING, "hello"); graph.declareIndex(0, "nodes", new Callback<NodeIndex>() { @Override public void on(NodeIndex indexNode) { indexNode.update(node); } }, "name"); Assert.assertEquals("{\"world\":0,\"time\":0,\"id\":1,\"group\":0,\"name\":\"hello\"}", node.toString()); int port = 8050; try { ServerSocket servSock = new ServerSocket(0); port = servSock.getLocalPort(); servSock.close(); } catch (IOException e) { e.printStackTrace(); } WSSharedServer graphServer = new WSSharedServer(graph, port); graphServer.start(); final CountDownLatch latch = new CountDownLatch(1); final Graph graph2 = new GraphBuilder().withMemorySize(10000).withStorage(new WSClient("ws: graph2.connect(new Callback<Boolean>() { @Override public void on(Boolean result1) { graph2.index(0, 0, "nodes", new Callback<NodeIndex>() { @Override public void on(NodeIndex indexNodes) { indexNodes.findFrom(new Callback<Node[]>() { @Override public void on(Node[] result1) { Assert.assertEquals(result1[0].toString(), node.toString()); Node newNode = graph2.newNode(0, 0); newNode.set("name", Type.STRING, "hello2"); Assert.assertEquals("{\"world\":0,\"time\":0,\"id\":137438953473,\"group\":0,\"name\":\"hello2\"}", newNode.toString()); graph2.declareIndex(0, "nodes", new Callback<NodeIndex>() { @Override public void on(NodeIndex graph2Nodes) { graph2Nodes.update(newNode); graph2Nodes.find(new Callback<Node[]>() { @Override public void on(Node[] result) { Assert.assertEquals(2, result.length); } }, graph2Nodes.world(), graph2Nodes.time()); } }, "name"); graph2.save(new Callback<Boolean>() { @Override public void on(Boolean result) { graph.index(0, 0, "nodes", new Callback<NodeIndex>() { @Override public void on(NodeIndex grapIndex) { grapIndex.find(new Callback<Node[]>() { @Override public void on(Node[] result) { Assert.assertEquals(2, result.length); Assert.assertEquals(result[0].toString(), "{\"world\":0,\"time\":0,\"id\":1,\"group\":0,\"name\":\"hello\"}"); Assert.assertEquals(result[1].toString(), "{\"world\":0,\"time\":0,\"id\":137438953473,\"group\":0,\"name\":\"hello2\"}"); latch.countDown(); } }, grapIndex.world(), grapIndex.time()); } }); } }); } }); } }); } }); try { latch.await(); } catch (InterruptedException e) { e.printStackTrace(); } } }); }