You interact with SockJS clients through instances of SockJS socket.

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

  • SockJSSocket
    • Basic
      • Identifiable
      • Object
        • Anything
    • ReadStream
      • StreamBase
    • WriteStream
      • StreamBase

no subtypes hierarchy

SockJSSocket(SockJSSocket unknown)
Inherited Attributes
Attributes inherited from: Object
hash, string
closeshared default void close()

Close it

drainHandlershared actual default SockJSSocket drainHandler(Anything() handler)

Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See Pump for an example of this being used.

The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to maxSize / 2.

Refines WriteStream.drainHandler
endshared actual default void end()

Call end.

Refines WriteStream.end
endshared actual default void end(Buffer t)
endHandlershared actual default SockJSSocket endHandler(Anything() endHandler)

Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

Refines ReadStream.endHandler
exceptionHandlershared actual default SockJSSocket exceptionHandler(Anything(Throwable) handler)

Set an exception handler.

Refines StreamBase.exceptionHandler
handlershared actual default SockJSSocket handler(Anything(Buffer) handler)

Set a data handler. As data is read, the handler will be called with the data.

Refines ReadStream.handler
headersshared default MultiMap headers()

Return the headers corresponding to the last request for this socket or the websocket handshake Any cookie headers will be removed for security reasons

localAddressshared default SocketAddress localAddress()

Return the local address for this socket

pauseshared actual default SockJSSocket pause()

Pause the ReadSupport. While it's paused, no data will be sent to the dataHandler

Refines ReadStream.pause
remoteAddressshared default SocketAddress remoteAddress()

Return the remote address for this socket

resumeshared actual default SockJSSocket resume()

Resume reading. If the ReadSupport has been paused, reading will recommence on it.

Refines ReadStream.resume
setWriteQueueMaxSizeshared actual default SockJSSocket setWriteQueueMaxSize(Integer maxSize)

Set the maximum size of the write queue to maxSize. You will still be able to write to the stream even if there is more than maxSize items in the write queue. This is used as an indicator by classes such as Pump to provide flow control.

The value is defined by the implementation of the stream, e.g in bytes for a NetSocket, the number of Message for a MessageProducer, etc…

Refines WriteStream.setWriteQueueMaxSize
urishared default String uri()

Return the URI corresponding to the last request for this socket or the websocket handshake

webSessionshared default Session? webSession()
webUsershared default User? webUser()
writeshared actual default SockJSSocket write(Buffer data)
writeshared default SockJSSocket write(String data)

Write a String to the socket, encoded in UTF-8.

  • data

    the string to write

writeHandlerIDshared default String writeHandlerID()

When a SockJSSocket is created it automatically registers an event handler with the event bus, the ID of that handler is given by writeHandlerID.

Given this ID, a different event loop can send a buffer to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying socket. This allows you to write data to other sockets which are owned by different event loops.

writeQueueFullshared actual default Boolean writeQueueFull()

This will return true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize

Refines WriteStream.writeQueueFull
Inherited Methods
Methods inherited from: Object
Methods inherited from: ReadStream<T>
endHandler, exceptionHandler, handler, pause, resume
Methods inherited from: StreamBase
Methods inherited from: WriteStream<T>
drainHandler, end, exceptionHandler, setWriteQueueMaxSize, write, writeQueueFull