Example #1
0
 /**
  * Like {@link io.vertx.golo.core.eventbus.EventBus#send} but specifying <code>options</code> that
  * can be used to configure the delivery.
  *
  * @param address the address to send it to
  * @param message the message, may be <code>null</code>
  * @param options delivery options (see <a
  *     href="../../../../../../../cheatsheet/DeliveryOptions.html">DeliveryOptions</a>)
  * @return a reference to this, so the API can be used fluently
  */
 public EventBus send(String address, Object message, Map<String, Object> options) {
   this.delegate.send(
       address,
       InternalHelper.unwrapObject(message),
       options != null
           ? new io.vertx.core.eventbus.DeliveryOptions(new io.vertx.core.json.JsonObject(options))
           : null);
   return this;
 }
Example #2
0
 /**
  * Like {@link io.vertx.golo.core.eventbus.EventBus#publisher} but specifying delivery options
  * that will be used for configuring the delivery of the message.
  *
  * @param address the address to publish it to
  * @param options the delivery options (see <a
  *     href="../../../../../../../cheatsheet/DeliveryOptions.html">DeliveryOptions</a>)
  * @return The publisher
  */
 public <T> MessageProducer<T> publisher(String address, Map<String, Object> options) {
   return InternalHelper.safeCreate(
       this.delegate.publisher(
           address,
           options != null
               ? new io.vertx.core.eventbus.DeliveryOptions(
                   new io.vertx.core.json.JsonObject(options))
               : null),
       io.vertx.golo.core.eventbus.MessageProducer.class);
 }
Example #3
0
 /**
  * Like {@link io.vertx.golo.core.eventbus.EventBus#consumer} but the address won't be propagated
  * across the cluster.
  *
  * @param address the address that will register it at
  * @param handler the handler that will process the received messages
  * @return the event bus message consumer
  */
 public <T> MessageConsumer<T> localConsumer(String address, Handler<Message<T>> handler) {
   return InternalHelper.safeCreate(
       this.delegate.localConsumer(
           address,
           new Handler<io.vertx.core.eventbus.Message<java.lang.Object>>() {
             public void handle(io.vertx.core.eventbus.Message<java.lang.Object> event) {
               handler.handle(new io.vertx.golo.core.eventbus.Message(event));
             }
           }),
       io.vertx.golo.core.eventbus.MessageConsumer.class);
 }
Example #4
0
 /**
  * Like {@link io.vertx.golo.core.eventbus.EventBus#send} but specifying a <code>replyHandler
  * </code> that will be called if the recipient subsequently replies to the message.
  *
  * @param address the address to send it to
  * @param message the message, may be <code>null</code>
  * @param replyHandler reply handler will be called when any reply from the recipient is received,
  *     may be <code>null</code>
  * @return a reference to this, so the API can be used fluently
  */
 public <T> EventBus send(
     String address, Object message, Handler<AsyncResult<Message<T>>> replyHandler) {
   this.delegate.send(
       address,
       InternalHelper.unwrapObject(message),
       new Handler<AsyncResult<io.vertx.core.eventbus.Message<java.lang.Object>>>() {
         public void handle(AsyncResult<io.vertx.core.eventbus.Message<java.lang.Object>> event) {
           AsyncResult<Message<Object>> f;
           if (event.succeeded()) {
             f = InternalHelper.<Message<Object>>result(new Message<Object>(event.result()));
           } else {
             f = InternalHelper.<Message<Object>>failure(event.cause());
           }
           replyHandler.handle((AsyncResult) f);
         }
       });
   return this;
 }
 /**
  * @return the query parameters in the request
  * @return
  */
 public MultiMap params() {
   return InternalHelper.safeCreate(this.delegate.params(), io.vertx.golo.core.MultiMap.class);
 }
 /**
  * @return the response. Each instance of this class has an {@link
  *     io.vertx.golo.core.http.HttpServerResponse} instance attached to it. This is used to send
  *     the response back to the client.
  * @return
  */
 public HttpServerResponse response() {
   return InternalHelper.safeCreate(
       this.delegate.response(), io.vertx.golo.core.http.HttpServerResponse.class);
 }
Example #7
0
 /**
  * Returns a slice of this buffer. Modifying the content of the returned buffer or this buffer
  * affects each other's content while they maintain separate indexes and marks.
  *
  * @param start
  * @param end
  * @return
  */
 public Buffer slice(int start, int end) {
   return InternalHelper.safeCreate(
       this.delegate.slice(start, end), io.vertx.golo.core.buffer.Buffer.class);
 }
Example #8
0
 /**
  * Create a new buffer from a string and using the specified encoding. The string will be encoded
  * into the buffer using the specified encoding.
  *
  * @param string the string
  * @param enc
  * @return the buffer
  */
 public static Buffer buffer(String string, String enc) {
   return InternalHelper.safeCreate(
       io.vertx.core.buffer.Buffer.buffer(string, enc), io.vertx.golo.core.buffer.Buffer.class);
 }
Example #9
0
 /**
  * Returns a copy of the entire Buffer.
  *
  * @return
  */
 public Buffer copy() {
   return InternalHelper.safeCreate(this.delegate.copy(), io.vertx.golo.core.buffer.Buffer.class);
 }
 /**
  * Returns a map of all form attributes in the request.
  *
  * <p>Be aware that the attributes will only be available after the whole body has been received,
  * i.e. after the request end handler has been called.
  *
  * <p>{@link io.vertx.golo.core.http.HttpServerRequest#setExpectMultipart} must be called first
  * before trying to get the form attributes.
  *
  * @return the form attributes
  */
 public MultiMap formAttributes() {
   return InternalHelper.safeCreate(
       this.delegate.formAttributes(), io.vertx.golo.core.MultiMap.class);
 }
Example #11
0
 /**
  * Create a new, empty buffer.
  *
  * @return the buffer
  */
 public static Buffer buffer() {
   return InternalHelper.safeCreate(
       io.vertx.core.buffer.Buffer.buffer(), io.vertx.golo.core.buffer.Buffer.class);
 }
Example #12
0
 /**
  * Sends a message.
  *
  * <p>The message will be delivered to at most one of the handlers registered to the address.
  *
  * @param address the address to send it to
  * @param message the message, may be <code>null</code>
  * @return a reference to this, so the API can be used fluently
  */
 public EventBus send(String address, Object message) {
   this.delegate.send(address, InternalHelper.unwrapObject(message));
   return this;
 }
Example #13
0
 /**
  * Create a message publisher against the specified address.
  *
  * <p>The returned publisher will invoke the {@link io.vertx.golo.core.eventbus.EventBus#publish}
  * method when the stream {@link io.vertx.golo.core.streams.WriteStream#write} method is called
  * with the publisher address and the provided data.
  *
  * @param address The address to publish it to
  * @return The publisher
  */
 public <T> MessageProducer<T> publisher(String address) {
   return InternalHelper.safeCreate(
       this.delegate.publisher(address), io.vertx.golo.core.eventbus.MessageProducer.class);
 }
 /**
  * @return the local (server side) address of the server that handles the request
  * @return
  */
 public SocketAddress localAddress() {
   return InternalHelper.safeCreate(
       this.delegate.localAddress(), io.vertx.golo.core.net.SocketAddress.class);
 }
Example #15
0
 /**
  * Create a new buffer given the initial size hint.
  *
  * <p>If you know the buffer will require a certain size, providing the hint can prevent
  * unnecessary re-allocations as the buffer is written to and resized.
  *
  * @param initialSizeHint the hint, in bytes
  * @return the buffer
  */
 public static Buffer buffer(int initialSizeHint) {
   return InternalHelper.safeCreate(
       io.vertx.core.buffer.Buffer.buffer(initialSizeHint),
       io.vertx.golo.core.buffer.Buffer.class);
 }
 /**
  * Get a net socket for the underlying connection of this request.
  *
  * <p>USE THIS WITH CAUTION!
  *
  * <p>Once you have called this method, you must handle writing to the connection yourself using
  * the net socket, the server request instance will no longer be usable as normal. Writing to the
  * socket directly if you don't know what you're doing can easily break the HTTP protocol.
  *
  * @return the net socket
  */
 public NetSocket netSocket() {
   return InternalHelper.safeCreate(
       this.delegate.netSocket(), io.vertx.golo.core.net.NetSocket.class);
 }
Example #17
0
 /**
  * Sets the unsigned <code>byte</code> at position <code>pos</code> in the Buffer to the value
  * <code>b</code>.
  *
  * <p>The buffer will expand as necessary to accommodate any value written.
  *
  * @param pos
  * @param b
  * @return
  */
 public Buffer setUnsignedByte(int pos, short b) {
   return InternalHelper.safeCreate(
       this.delegate.setUnsignedByte(pos, b), io.vertx.golo.core.buffer.Buffer.class);
 }
 /**
  * Upgrade the connection to a WebSocket connection.
  *
  * <p>This is an alternative way of handling WebSockets and can only be used if no websocket
  * handlers are set on the Http server, and can only be used during the upgrade request during the
  * WebSocket handshake.
  *
  * @return the WebSocket
  */
 public ServerWebSocket upgrade() {
   return InternalHelper.safeCreate(
       this.delegate.upgrade(), io.vertx.golo.core.http.ServerWebSocket.class);
 }
Example #19
0
 /**
  * Like {@link io.vertx.golo.core.eventbus.EventBus#consumer} but the address won't be propagated
  * across the cluster.
  *
  * @param address the address to register it at
  * @return the event bus message consumer
  */
 public <T> MessageConsumer<T> localConsumer(String address) {
   return InternalHelper.safeCreate(
       this.delegate.localConsumer(address), io.vertx.golo.core.eventbus.MessageConsumer.class);
 }