org.vertx.java.core.http.HttpClient.connectWebsocket()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中org.vertx.java.core.http.HttpClient.connectWebsocket()方法的一些代码示例,展示了HttpClient.connectWebsocket()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.connectWebsocket()方法的具体详情如下:
包路径:org.vertx.java.core.http.HttpClient
类名称:HttpClient
方法名:connectWebsocket

HttpClient.connectWebsocket介绍

[英]Attempt to connect an HTML5 websocket to the specified URI

The connect is done asynchronously and wsConnect is called back with the websocket
[中]

代码示例

代码示例来源:origin: io.vertx/mod-rxvertx

public Observable<RxWebSocket> connectWebsocket(String uri, WebSocketVersion wsVersion, MultiMap headers) {
 final MemoizeHandler<RxWebSocket,WebSocket> rh=new MemoizeHandler<RxWebSocket,WebSocket>() {
  @Override
  public void handle(WebSocket s) {
   complete(new RxWebSocket(s));
  }
 };
 core.connectWebsocket(uri,wsVersion,headers,rh);
 return Observable.create(rh.subscribe);
}

代码示例来源:origin: vert-x/mod-lang-php

/**
 * Attempts to connect a websocket to the uri.
 */
public HttpClient connectWebsocket(Env env, StringValue uri, Value handler) {
 // TODO This method needs to be able to support other HttpClient.connectWebsocket() arguments.
 PhpTypes.assertCallable(env, handler, "Argument to Vertx\\Http\\HttpClient::connectWebsocket() must be callable.");
 client.connectWebsocket(uri.toString(), new Handler<org.vertx.java.core.http.WebSocket>(env, PhpTypes.toCallable(handler), new ResultModifier<org.vertx.java.core.http.WebSocket, WebSocket>() {
  @Override
  public WebSocket modify(org.vertx.java.core.http.WebSocket socket) {
   return new WebSocket(socket);
  }
 }));
 return this;
}

代码示例来源:origin: RichardHightower/slumberdb

private void connectWebSocket() {
  if (verbose) puts("Calling connectWebSocket");
  if (clientToServerWeAreAProxyFor == null) {
    this.connectHttpClient();
  }
  webSocket(null);
  clientToServerWeAreAProxyFor.connectWebsocket(uri, new Handler<WebSocket>() {
    @Override
    public void handle(WebSocket webSocket) {
      if (verbose) puts("Connected WebSocket", webSocket);
      webSocket(webSocket);
      connectToFrameStream(webSocket);
      connectToExceptionHandler(webSocket);
      connectToEndHandler(webSocket);
    }
  });
}

相关文章