我有一个使用底部的简单websocket服务器。
如何在此方法中使用UndertowClient对其他微服务进行HTTP调用?
任何指针?
@OnMessage
public String onMessage(String message) {
//Receive request -- make async micro call - Response will be sent later
return "request received";
}
感谢
答案 0 :(得分:0)
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();