Class SockJSSocket

java.lang.Object
io.vertx.mutiny.ext.web.handler.sockjs.SockJSSocket
All Implemented Interfaces:
MutinyDelegate, ReadStream<Buffer>, StreamBase, WriteStream<Buffer>

public class SockJSSocket extends Object implements MutinyDelegate, ReadStream<Buffer>, WriteStream<Buffer>
You interact with SockJS clients through instances of SockJS socket.

The API is very similar to WebSocket. It implements both and so it can be used with Pump to pump data with flow control.

NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

  • Field Details

  • Constructor Details

    • SockJSSocket

      public SockJSSocket(io.vertx.ext.web.handler.sockjs.SockJSSocket delegate)
    • SockJSSocket

      public SockJSSocket(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.ext.web.handler.sockjs.SockJSSocket getDelegate()
      Specified by:
      getDelegate in interface MutinyDelegate
      Specified by:
      getDelegate in interface ReadStream<Buffer>
      Specified by:
      getDelegate in interface StreamBase
      Specified by:
      getDelegate in interface WriteStream<Buffer>
      Returns:
      the delegate used by this Mutiny object of generated type
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toSubscriber

      @CheckReturnValue public WriteStreamSubscriber<Buffer> toSubscriber()
    • end

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> end()
      Description copied from interface: WriteStream
      Same as WriteStream.end() but with an handler called when the operation completes

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Specified by:
      end in interface WriteStream<Buffer>
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • endAndAwait

      public Void endAndAwait()
      Description copied from interface: WriteStream
      Blocking variant of WriteStream.end().

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Specified by:
      endAndAwait in interface WriteStream<Buffer>
      Returns:
      the Void instance produced by the operation.
    • endAndForget

      public void endAndForget()
      Description copied from interface: WriteStream
      Variant of WriteStream.end() that ignores the result of the operation.

      This method subscribes on the result of WriteStream.end(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from WriteStream.end() but you don't need to compose it with other operations.

      Specified by:
      endAndForget in interface WriteStream<Buffer>
    • end

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> end(Buffer data)
      Description copied from interface: WriteStream
      Same as but with an handler called when the operation completes

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Specified by:
      end in interface WriteStream<Buffer>
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • endAndAwait

      public Void endAndAwait(Buffer data)
      Description copied from interface: WriteStream
      Blocking variant of WriteStream.end(T).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Specified by:
      endAndAwait in interface WriteStream<Buffer>
      Returns:
      the Void instance produced by the operation.
    • endAndForget

      public void endAndForget(Buffer data)
      Description copied from interface: WriteStream
      Variant of WriteStream.end(T) that ignores the result of the operation.

      This method subscribes on the result of WriteStream.end(T), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from WriteStream.end(T) but you don't need to compose it with other operations.

      Specified by:
      endAndForget in interface WriteStream<Buffer>
    • writeQueueFull

      public boolean writeQueueFull()
      Specified by:
      writeQueueFull in interface WriteStream<Buffer>
      Returns:
      true if write queue is full
    • pipe

      public Pipe<Buffer> pipe()
      Specified by:
      pipe in interface ReadStream<Buffer>
      Returns:
      a pipe
    • pipeTo

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<Buffer> dst)
      Description copied from interface: ReadStream
      Pipe this ReadStream to the WriteStream.

      Elements emitted by this stream will be written to the write stream until this stream ends or fails.

      Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Specified by:
      pipeTo in interface ReadStream<Buffer>
      Parameters:
      dst - the destination write stream
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • pipeToAndAwait

      public Void pipeToAndAwait(WriteStream<Buffer> dst)
      Description copied from interface: ReadStream
      Blocking variant of ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Specified by:
      pipeToAndAwait in interface ReadStream<Buffer>
      Parameters:
      dst - the destination write stream
      Returns:
      the Void instance produced by the operation.
    • pipeToAndForget

      public void pipeToAndForget(WriteStream<Buffer> dst)
      Description copied from interface: ReadStream
      Variant of ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream) that ignores the result of the operation.

      This method subscribes on the result of ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from ReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream) but you don't need to compose it with other operations.

      Specified by:
      pipeToAndForget in interface ReadStream<Buffer>
      Parameters:
      dst - the destination write stream
    • exceptionHandler

      public SockJSSocket exceptionHandler(Consumer<Throwable> handler)
      Specified by:
      exceptionHandler in interface ReadStream<Buffer>
      Specified by:
      exceptionHandler in interface StreamBase
      Specified by:
      exceptionHandler in interface WriteStream<Buffer>
      Parameters:
      handler - the exception handler
      Returns:
    • handler

      public SockJSSocket handler(Consumer<Buffer> handler)
      Specified by:
      handler in interface ReadStream<Buffer>
      Returns:
    • pause

      public SockJSSocket pause()
      Specified by:
      pause in interface ReadStream<Buffer>
      Returns:
      a reference to this, so the API can be used fluently
    • resume

      public SockJSSocket resume()
      Specified by:
      resume in interface ReadStream<Buffer>
      Returns:
      a reference to this, so the API can be used fluently
    • fetch

      public SockJSSocket fetch(long amount)
      Specified by:
      fetch in interface ReadStream<Buffer>
      Returns:
      a reference to this, so the API can be used fluently
    • endHandler

      public SockJSSocket endHandler(Runnable endHandler)
      Specified by:
      endHandler in interface ReadStream<Buffer>
      Returns:
    • closeHandler

      public SockJSSocket closeHandler(Runnable closeHandler)
    • write

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> write(String data)
    • writeAndAwait

      public Void writeAndAwait(String data)
    • writeAndForget

      public void writeAndForget(String data)
    • write

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> write(Buffer data)
      Description copied from interface: WriteStream
      Same as but with an handler called when the operation completes

      Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

      Specified by:
      write in interface WriteStream<Buffer>
      Returns:
      the uni firing the result of the operation when completed, or a failure if the operation failed.
    • writeAndAwait

      public Void writeAndAwait(Buffer data)
      Description copied from interface: WriteStream
      Blocking variant of WriteStream.write(T).

      This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Specified by:
      writeAndAwait in interface WriteStream<Buffer>
      Returns:
      the Void instance produced by the operation.
    • writeAndForget

      public void writeAndForget(Buffer data)
      Description copied from interface: WriteStream
      Variant of WriteStream.write(T) that ignores the result of the operation.

      This method subscribes on the result of WriteStream.write(T), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from WriteStream.write(T) but you don't need to compose it with other operations.

      Specified by:
      writeAndForget in interface WriteStream<Buffer>
    • setWriteQueueMaxSize

      public SockJSSocket setWriteQueueMaxSize(int maxSize)
      Specified by:
      setWriteQueueMaxSize in interface WriteStream<Buffer>
      Parameters:
      maxSize - the max size of the write stream
      Returns:
      a reference to this, so the API can be used fluently
    • drainHandler

      public SockJSSocket drainHandler(Runnable handler)
      Specified by:
      drainHandler in interface WriteStream<Buffer>
      Parameters:
      handler - the handler
      Returns:
    • writeHandlerID

      public String writeHandlerID()
      Returns:
      the writeHandlerID or null if writeHandler registration is disabled in SockJSHandlerOptions
    • close

      public void close()
    • close

      public void close(int statusCode, String reason)
      Parameters:
      statusCode -
      reason -
    • remoteAddress

      public SocketAddress remoteAddress()
      Returns:
    • localAddress

      public SocketAddress localAddress()
      Returns:
    • headers

      public MultiMap headers()
      Returns:
    • uri

      public String uri()
      Returns:
    • routingContext

      public RoutingContext routingContext()
      Returns:
      the Vert.x-Web RoutingContext corresponding to this socket
    • webSession

      public Session webSession()
      Returns:
      the Vert.x-Web session corresponding to this socket
    • webUser

      public User webUser()
      Returns:
      the Vert.x-Web user corresponding to this socket
    • toMulti

      @CheckReturnValue public io.smallrye.mutiny.Multi<Buffer> toMulti()
      Specified by:
      toMulti in interface ReadStream<Buffer>
    • toBlockingIterable

      public Iterable<Buffer> toBlockingIterable()
    • toBlockingStream

      public Stream<Buffer> toBlockingStream()
    • newInstance

      public static SockJSSocket newInstance(io.vertx.ext.web.handler.sockjs.SockJSSocket arg)