io.vertx.core.http.HttpConnection.ping()方法的使用及代码示例

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

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

HttpConnection.ping介绍

[英]Send a PING frame to the remote endpoint.

This is not implemented for HTTP/1.x.
[中]向远程端点发送PING帧。
这不是为HTTP/1实现的。十、

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testReceivePing() throws Exception {
 Buffer expected = TestUtils.randomBuffer(8);
 Context ctx = vertx.getOrCreateContext();
 server.close();
 server.connectionHandler(conn -> {
  conn.ping(expected, ar -> {
  });
 });
 server.requestHandler(req -> {});
 startServer(ctx);
 HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> {
 });
 req.connectionHandler(conn -> {
  conn.pingHandler(data -> {
   assertEquals(expected, data);
   complete();
  });
 });
 req.end();
 await();
}

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Send a  frame to the remote endpoint.
 * <p/>
 * This is not implemented for HTTP/1.x.
 * @param data the 8 bytes data of the frame
 * @param pongHandler an async result handler notified with pong reply or the failure
 * @return a reference to this, so the API can be used fluently
 */
public io.vertx.rxjava.core.http.HttpConnection ping(io.vertx.rxjava.core.buffer.Buffer data, Handler<AsyncResult<io.vertx.rxjava.core.buffer.Buffer>> pongHandler) { 
 delegate.ping(data.getDelegate(), new Handler<AsyncResult<io.vertx.core.buffer.Buffer>>() {
  public void handle(AsyncResult<io.vertx.core.buffer.Buffer> ar) {
   if (ar.succeeded()) {
    pongHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.buffer.Buffer.newInstance(ar.result())));
   } else {
    pongHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
   }
  }
 });
 return this;
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testSendPing() throws Exception {
 waitFor(2);
 Buffer expected = TestUtils.randomBuffer(8);
 Context ctx = vertx.getOrCreateContext();
 server.close();
 server.connectionHandler(conn -> {
  conn.pingHandler(data -> {
   assertEquals(expected, data);
   complete();
  });
 });
 server.requestHandler(req -> {});
 startServer(ctx);
 HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> {
 });
 req.connectionHandler(conn -> {
  conn.ping(expected, ar -> {
   assertTrue(ar.succeeded());
   Buffer buff = ar.result();
   assertEquals(expected, buff);
   complete();
  });
 });
 req.end();
 await();
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * Send a  frame to the remote endpoint.
 * <p/>
 * This is not implemented for HTTP/1.x.
 * @param data the 8 bytes data of the frame
 * @param pongHandler an async result handler notified with pong reply or the failure
 * @return a reference to this, so the API can be used fluently
 */
public io.vertx.rxjava.core.http.HttpConnection ping(io.vertx.rxjava.core.buffer.Buffer data, Handler<AsyncResult<io.vertx.rxjava.core.buffer.Buffer>> pongHandler) { 
 delegate.ping(data.getDelegate(), new Handler<AsyncResult<io.vertx.core.buffer.Buffer>>() {
  public void handle(AsyncResult<io.vertx.core.buffer.Buffer> ar) {
   if (ar.succeeded()) {
    pongHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.buffer.Buffer.newInstance(ar.result())));
   } else {
    pongHandler.handle(io.vertx.core.Future.failedFuture(ar.cause()));
   }
  }
 });
 return this;
}

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

@Test
public void testReceivePing() throws Exception {
 Buffer expected = TestUtils.randomBuffer(8);
 Context ctx = vertx.getOrCreateContext();
 server.close();
 server.connectionHandler(conn -> {
  conn.ping(expected, ar -> {
  });
 });
 server.requestHandler(req -> {});
 startServer(ctx);
 HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> {
 });
 req.connectionHandler(conn -> {
  conn.pingHandler(data -> {
   assertEquals(expected, data);
   complete();
  });
 });
 req.end();
 await();
}

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

@Test
public void testSendPing() throws Exception {
 waitFor(2);
 Buffer expected = TestUtils.randomBuffer(8);
 Context ctx = vertx.getOrCreateContext();
 server.close();
 server.connectionHandler(conn -> {
  conn.pingHandler(data -> {
   assertEquals(expected, data);
   complete();
  });
 });
 server.requestHandler(req -> {});
 startServer(ctx);
 HttpClientRequest req = client.get(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, "/somepath", resp -> {
 });
 req.connectionHandler(conn -> {
  conn.ping(expected, ar -> {
   assertTrue(ar.succeeded());
   Buffer buff = ar.result();
   assertEquals(expected, buff);
   complete();
  });
 });
 req.end();
 await();
}

相关文章