-
- All Superinterfaces:
ReadStream<Buffer>,StreamBase,WriteStream<Buffer>
public interface SockJSSocket extends ReadStream<Buffer>, WriteStream<Buffer>
You interact with SockJS clients through instances of SockJS socket.The API is very similar to
WebSocket. It implements bothReadStreamandWriteStreamso it can be used withio.vertx.core.streams.Pumpto pump data with flow control.- Author:
- Tim Fox
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()Close itdefault voidclose(int statusCode, String reason)Close it giving a status code and reason.SockJSSocketcloseHandler(Handler<Void> closeHandler)SockJSSocketdrainHandler(Handler<Void> handler)Future<Void>end()Callclose().SockJSSocketendHandler(Handler<Void> endHandler)SockJSSocketexceptionHandler(Handler<Throwable> handler)SockJSSocketfetch(long amount)SockJSSockethandler(Handler<Buffer> handler)MultiMapheaders()Return the headers corresponding to the last request for this socket or the websocket handshake Any cookie headers will be removed for security reasonsSocketAddresslocalAddress()Return the local address for this socketSockJSSocketpause()SocketAddressremoteAddress()Return the remote address for this socketSockJSSocketresume()RoutingContextroutingContext()SockJSSocketsetWriteQueueMaxSize(int maxSize)Stringuri()Return the URI corresponding to the last request for this socket or the websocket handshakeSessionwebSession()UserwebUser()Future<Void>write(Buffer data)default Future<Void>write(String data)Write aStringto the socket, encoded in UTF-8.StringwriteHandlerID()When aSockJSSocketis created it can register an event handler with the event bus, the ID of that handler is given bywriteHandlerID.-
Methods inherited from interface io.vertx.core.streams.ReadStream
blockingStream, collect, pipe, pipeTo
-
Methods inherited from interface io.vertx.core.streams.WriteStream
end, writeQueueFull
-
-
-
-
Method Detail
-
exceptionHandler
SockJSSocket exceptionHandler(Handler<Throwable> handler)
- Specified by:
exceptionHandlerin interfaceReadStream<Buffer>- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<Buffer>
-
handler
SockJSSocket handler(Handler<Buffer> handler)
- Specified by:
handlerin interfaceReadStream<Buffer>
-
pause
SockJSSocket pause()
- Specified by:
pausein interfaceReadStream<Buffer>
-
resume
SockJSSocket resume()
- Specified by:
resumein interfaceReadStream<Buffer>
-
fetch
SockJSSocket fetch(long amount)
- Specified by:
fetchin interfaceReadStream<Buffer>
-
endHandler
SockJSSocket endHandler(Handler<Void> endHandler)
- Specified by:
endHandlerin interfaceReadStream<Buffer>
-
closeHandler
SockJSSocket closeHandler(Handler<Void> closeHandler)
-
write
default Future<Void> write(String data)
Write aStringto the socket, encoded in UTF-8.- Parameters:
data- the string to write
-
setWriteQueueMaxSize
SockJSSocket setWriteQueueMaxSize(int maxSize)
- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<Buffer>
-
drainHandler
SockJSSocket drainHandler(Handler<Void> handler)
- Specified by:
drainHandlerin interfaceWriteStream<Buffer>
-
writeHandlerID
String writeHandlerID()
When aSockJSSocketis created it can register an event handler with the event bus, the ID of that handler is given bywriteHandlerID.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.
- Returns:
- the
writeHandlerIDornullifwriteHandlerregistration is disabled inSockJSHandlerOptions
-
close
void close()
Close it
-
close
default void close(int statusCode, String reason)Close it giving a status code and reason. Only Applicable to RawWebSocket will downgrade to plain close for other transports.
-
remoteAddress
SocketAddress remoteAddress()
Return the remote address for this socket
-
localAddress
SocketAddress localAddress()
Return the local address for this socket
-
headers
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
-
uri
String uri()
Return the URI corresponding to the last request for this socket or the websocket handshake
-
routingContext
RoutingContext routingContext()
- Returns:
- the Vert.x-Web RoutingContext corresponding to this socket
-
webSession
Session webSession()
- Returns:
- the Vert.x-Web session corresponding to this socket
-
webUser
User webUser()
- Returns:
- the Vert.x-Web user corresponding to this socket
-
-