0

我有一个使用 undertow 的简单 websocket 服务器。

如何在此方法中使用 UndertowClient 对其他微服务进行 HTTP 调用?

任何指针?

@OnMessage
public String onMessage(String message) {
    //Receive request -- make async micro call - Response will be sent later
    return "request received";
}

谢谢

4

1 回答 1

0

取自这里: https ://github.com/undertow-io/undertow/blob/master/websockets-jsr/src/test/java/io/undertow/websockets/jsr/test/JsrWebSocketServer07Test.java


import io.undertow.websockets.utils.WebSocketTestClient;
...
WebSocketTestClient client = new WebSocketTestClient(getVersion(), new URI("ws://" + NetworkUtils.formatPossibleIpv6Address(DefaultServer.getHostAddress("default")) + ":" + DefaultServer.getHostPort("default") + "/"));
    client.connect();
    client.send(new BinaryWebSocketFrame(Unpooled.wrappedBuffer(payload)), new FrameChecker(BinaryWebSocketFrame.class, payload, latch));
    latch.getIoFuture().get();
    Assert.assertNull(cause.get());
    client.destroy();
于 2015-05-19T10:21:00.783 回答