Examples of VoidHandler


Examples of org.vertx.java.core.VoidHandler

                                        LOG.debug("3. Proxying response body:" + data);
                                    }
                                    request.response().write(data);
                                }
                            });
                            clientResponse.endHandler(new VoidHandler() {
                                public void handle() {
                                    request.response().end();
                                    //finalClient.close();
                                    if (LOG.isDebugEnabled()) {
                                        LOG.debug("4. Response end");
                                    }
                                }
                            });
                        }
                    };
                    if (mappedServices != null) {
                        ProxyMappingDetails proxyMappingDetails = new ProxyMappingDetails(proxyServiceUrl, reverseServiceUrl, servicePath);
                        responseHandler = mappedServices.wrapResponseHandlerInPolicies(request, responseHandler, proxyMappingDetails);
                    }
                    final HttpClientRequest clientRequest = client.request(request.method(), servicePath, responseHandler);
                    clientRequest.headers().set(request.headers());
                    clientRequest.setChunked(true);
                    request.dataHandler(new Handler<Buffer>() {
                        public void handle(Buffer data) {
                            if (LOG.isDebugEnabled()) {
                                LOG.debug("1. Proxying request body:" + data);
                            }
                            clientRequest.write(data);
                        }
                    });
                    request.endHandler(new VoidHandler() {
                        public void handle() {
                            if (LOG.isDebugEnabled()) {
                                LOG.debug("2. end of the request");
                            }
                            clientRequest.end();
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

              close();
            }
          }
        }
      });
      ws.closeHandler(new VoidHandler() {
        public void handle() {
          closed = true;
          session.shutdown();
        }
      });
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

  }

  protected static abstract class BaseListener implements TransportListener {

    protected void addCloseHandler(HttpServerResponse resp, final Session session) {
      resp.closeHandler(new VoidHandler() {
        public void handle() {
          if (log.isTraceEnabled()) log.trace("Connection closed (from client?), closing session");
          // Connection has been closed fron the client or network error so
          // we remove the session
          session.shutdown();
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

  }

  @Override
  public NetSocket drainHandler(Handler<Void> drainHandler) {
    this.drainHandler = drainHandler;
    vertx.runOnContext(new VoidHandler() {
      public void handle() {
        callDrainHandler(); //If the channel is already drained, we want to call it immediately
      }
    });
    return this;
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

          });
          serverChannelGroup.add(bindFuture.channel());
        } catch (final Throwable t) {
          // Make sure we send the exception back through the handler (if any)
          if (listenHandler != null) {
            vertx.runOnContext(new VoidHandler() {
              @Override
              protected void handle() {
                listenHandler.handle(new DefaultFutureResult<NetServer>(t));
              }
            });
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

          serverChannelGroup.add(serverChannel);
        } catch (final Throwable t) {
          t.printStackTrace();
          // Make sure we send the exception back through the handler (if any)
          if (listenHandler != null) {
            vertx.runOnContext(new VoidHandler() {
              @Override
              protected void handle() {
                listenHandler.handle(new DefaultFutureResult<HttpServer>(t));
              }
            });
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

        final long timerID = vertx.setPeriodic(1000, new Handler<Long>() {
          public void handle(Long id) {
            sock.write(new Buffer("tick!"));
          }
        });
        sock.endHandler(new VoidHandler() {
          public void handle() {
            vertx.cancelTimer(timerID);
          }
        });
      }
    });
    installApp(new JsonObject().putString("prefix", "/amplify")
                               .putNumber("max_bytes_streaming", 4096),
               new Handler<SockJSSocket>() {
      long timerID;
      public void handle(final SockJSSocket sock) {
        sock.dataHandler(new Handler<Buffer>() {
          public void handle(Buffer data) {
            String str = data.toString();
            int n = Integer.valueOf(str);
            if (n < 0 || n > 19) {
              n = 1;
            }
            int num = (int)Math.pow(2, n);
            Buffer buff = new Buffer(num);
            for (int i = 0; i < num; i++) {
              buff.appendByte((byte)'x');
            }
            sock.write(buff);
          }
        });
      }
    });
    installApp(new JsonObject().putString("prefix", "/broadcast")
                               .putNumber("max_bytes_streaming", 4096),
               new Handler<SockJSSocket>() {
      final Set<String> connections = vertx.sharedData().getSet("conns");
      public void handle(final SockJSSocket sock) {
        connections.add(sock.writeHandlerID());
        sock.dataHandler(new Handler<Buffer>() {
          public void handle(Buffer buffer) {
            for (String actorID : connections) {
              vertx.eventBus().publish(actorID, buffer);
            }
          }
        });
        sock.endHandler(new VoidHandler() {
          public void handle() {
            connections.remove(sock.writeHandlerID());
          }
        });
      }
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

  }

  private void createConn(Channel ch, Handler<ClientConnection> connectHandler) {
    final ClientConnection conn = new ClientConnection(vertx, DefaultHttpClient.this, ch,
        tcpHelper.isSSL(), host, port, keepAlive, actualCtx);
    conn.closeHandler(new VoidHandler() {
      public void handle() {
        pool.connectionClosed();
      }
    });
    connectionMap.put(ch, conn);
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

    dataHandler(new Handler<Buffer>() {
      public void handle(Buffer buff) {
        body.appendBuffer(buff);
      }
    });
    endHandler(new VoidHandler() {
      public void handle() {
        bodyHandler.handle(body);
      }
    });
    return this;
View Full Code Here

Examples of org.vertx.java.core.VoidHandler

  private void doResume() {
    if (pausedChunks != null) {
      Buffer chunk;
      while ((chunk = pausedChunks.poll()) != null) {
        final Buffer theChunk = chunk;
        vertx.runOnContext(new VoidHandler() {
          @Override
          protected void handle() {
            handleChunk(theChunk);
            // release the buffer after process it
            theChunk.getByteBuf().release();
          }
        });
      }
    }
    if (hasPausedEnd) {
      final LastHttpContent theTrailer = pausedTrailer;
      vertx.runOnContext(new VoidHandler() {
        @Override
        protected void handle() {
          handleEnd(theTrailer);
          // release the buffer after process it
          theTrailer.release();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.