Ejemplo n.º 1
0
 public void onComplete(
     final HttpClientResponse response, final AsyncResultHandler<Void> doneHandler) {
   final Buffer buff = new Buffer(16);
   response.dataHandler(
       new Handler<Buffer>() {
         public void handle(Buffer data) {
           buff.appendBuffer(data);
         }
       });
   response.endHandler(
       new SimpleHandler() {
         public void handle() {
           byte[] bytes = buff.getBytes();
           AsyncResult<Void> res;
           try {
             if (challenge.verify(bytes)) {
               res = new AsyncResult<>((Void) null);
             } else {
               res = new AsyncResult<>(new Exception("Invalid websocket handshake response"));
             }
           } catch (Exception e) {
             res = new AsyncResult<>(e);
           }
           doneHandler.handle(res);
         }
       });
 }
Ejemplo n.º 2
0
  public void onComplete(HttpClientResponse response, final CompletionHandler<Void> doneHandler) {

    final Buffer buff = Buffer.create(16);
    response.dataHandler(
        new Handler<Buffer>() {
          public void handle(Buffer data) {
            buff.appendBuffer(data);
          }
        });
    response.endHandler(
        new SimpleHandler() {
          public void handle() {
            byte[] bytes = buff.getBytes();
            SimpleFuture<Void> fut = new SimpleFuture<>();
            try {
              if (challenge.verify(bytes)) {
                fut.setResult(null);
              } else {
                fut.setException(new Exception("Invalid websocket handshake response"));
              }
            } catch (Exception e) {
              fut.setException(e);
            }
            doneHandler.handle(fut);
          }
        });
  }