new SockJSSocket(delegate)
Represents a SockJS socket. You interact with SockJS clients through
instances of a SockJS socket.
The API is very similar to module:vertx/http.WebSocket
.
Instances of this class are created and provided to a SockJSHandler
.
It implements both ReadStream
and WriteStream
so
it can be used with Pump
to pump data
with flow control.
Parameters:
Name | Type | Description |
---|---|---|
delegate |
org.vertx.java.core.sockjs.SockJSSocket | The java SockJSSocket object |
- Source:
- See:
Extends
Methods
-
close()
-
Close the socket
- Source:
-
dataHandler(handler)
-
Set a data handler. As data is read, the handler will be called with a Buffer containing the data read.
Parameters:
Name Type Description handler
BodyHandler the handler to call - Inherited From:
- Source:
-
drainHandler(handler)
-
Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue has been reduced to maxSize/2. See
module:vertx/pump~Pump
for an example of this being used.Parameters:
Name Type Description handler
Handler the handler to call when the stream has been drained - Inherited From:
- Source:
-
endHandler(handler)
-
Set an end handler. Once the stream has ended, and there is no more data to be read, the handler will be called.
Parameters:
Name Type Description handler
Handler the handler to call - Inherited From:
- Source:
-
exceptionHandler(handler)
-
Set an exception handler.
Parameters:
Name Type Description handler
Handler the handler to call - Inherited From:
- Source:
-
exceptionHandler(handler)
-
Set an exception handler on the stream
Parameters:
Name Type Description handler
Handler the handler to call when an exception occurs - Inherited From:
- Source:
-
headers() → {module:vertx/multi_map~MultiMap}
-
- Source:
Returns:
The headers map -
localAddress()
-
Get the local address for this socket
- Source:
Returns:
The address of the local socket -
pause()
-
Pause the
ReadStream
. While the stream is paused, no data will be sent to the data Handler- Inherited From:
- Source:
-
resume()
-
Resume reading. If the
ReadStream
has been paused, reading will recommence on it.- Inherited From:
- Source:
-
uri() → {string}
-
Return the URI corresponding to the last request for this socket or the websocket handshake
- Source:
Returns:
The URI string- Type
- string
-
write(data)
-
Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the module:vertx/streams~WriteStream#writeQueueFull method before writing. This is done automatically if using a
module:vertx/pump~Pump
.Parameters:
Name Type Description data
module:vertx/buffer~Buffer the data to write - Inherited From:
- Source:
-
writeHandlerID() → {string}
-
When a {@code 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.
- Source:
Returns:
the ID- Type
- string
-
writeQueueFull()
-
This will return
true
if there are more bytes in the write queue than the value set usingwriteQueueMaxSize
- Inherited From:
- Source:
-
writeQueueMaxSize(size)
-
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 thanmaxSize
bytes in the write queue. This is used as an indicator by classes such asPump
to provide flow control.Parameters:
Name Type Description size
number the size of the write queue - Inherited From:
- Source: