Class SockJSSocket
- All Implemented Interfaces:
MutinyDelegate,ReadStream<io.vertx.core.buffer.Buffer>,StreamBase,WriteStream<io.vertx.core.buffer.Buffer>
The API is very similar to WebSocket.
It implements both ReadStream and WriteStream
so it can be used with
io.vertx.core.streams.Pump to pump data with flow control.
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Tim Fox
- See Also:
-
SockJSSocket
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.ReadStream
ReadStream.ReadStreamImpl<T>Nested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.StreamBase
StreamBase.StreamBaseImplNested classes/interfaces inherited from interface io.vertx.mutiny.core.streams.WriteStream
WriteStream.WriteStreamImpl<T> -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSockJSSocket(io.vertx.ext.web.handler.sockjs.SockJSSocket delegate) Create a new instance ofSockJSSocketdelegating to the given (non-null) instance ofSockJSSocket.SockJSSocket(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close itvoidClose it giving a status code and reason.closeHandler(Runnable closeHandler) drainHandler(Runnable handler) Set a drain handler on the stream.io.smallrye.mutiny.Uni<Void>end()Callclose().io.smallrye.mutiny.Uni<Void>end(io.vertx.core.buffer.Buffer data) Same asend()but writes some data to the stream before ending.voidCallclose().voidendAndAwait(io.vertx.core.buffer.Buffer data) Same asend()but writes some data to the stream before ending.Callclose().endAndForget(io.vertx.core.buffer.Buffer data) Same asend()but writes some data to the stream before ending.endHandler(Runnable endHandler) Set an end handler.booleanexceptionHandler(Consumer<Throwable> handler) Set an exception handler on the read stream.fetch(long amount) Fetch the specifiedamountof elements.io.vertx.ext.web.handler.sockjs.SockJSSocketGet the delegate instance.Set a data handler.inthashCode()io.vertx.core.MultiMapheaders()Return the headers corresponding to the last request for this socket or the websocket handshake Any cookie headers will be removed for security reasonsio.vertx.core.net.SocketAddressReturn the local address for this socketstatic SockJSSocketnewInstance(io.vertx.ext.web.handler.sockjs.SockJSSocket delegate) Creates a new instance of theSockJSSocket.pause()Pause theReadStream, it sets the buffer infetchmode and clears the actual demand.Pipe<io.vertx.core.buffer.Buffer>pipe()Pause this stream and return aPipeto transfer the elements of this stream to a destinationWriteStream.io.smallrye.mutiny.Uni<Void>pipeTo(WriteStream<io.vertx.core.buffer.Buffer> dst) Pipe thisReadStreamto theWriteStream.voidpipeToAndAwait(WriteStream<io.vertx.core.buffer.Buffer> dst) Pipe thisReadStreamto theWriteStream.pipeToAndForget(WriteStream<io.vertx.core.buffer.Buffer> dst) Pipe thisReadStreamto theWriteStream.io.vertx.core.net.SocketAddressReturn the remote address for this socketresume()Resume reading, and sets the buffer inflowingmode.setWriteQueueMaxSize(int maxSize) Set the maximum size of the write queue tomaxSize.Iterable<io.vertx.core.buffer.Buffer>Stream<io.vertx.core.buffer.Buffer>io.smallrye.mutiny.Multi<io.vertx.core.buffer.Buffer>toMulti()toString()Flow.Subscriber<io.vertx.core.buffer.Buffer>Converts the current write stream to a subscriber.uri()Return the URI corresponding to the last request for this socket or the websocket handshakewebUser()io.smallrye.mutiny.Uni<Void>write(io.vertx.core.buffer.Buffer data) Unlike the bare Vert.x variant, this method returns aUni.io.smallrye.mutiny.Uni<Void>Write aStringto the socket, encoded in UTF-8.voidwriteAndAwait(io.vertx.core.buffer.Buffer data) Unlike the bare Vert.x variant, this method returns aVoid.voidwriteAndAwait(String data) Write aStringto the socket, encoded in UTF-8.writeAndForget(io.vertx.core.buffer.Buffer data) Unlike the bare Vert.x variant, this method ignores theVoidresult or any failure.writeAndForget(String data) Write aStringto the socket, encoded in UTF-8.When aSockJSSocketis created it can register an event handler with the event bus, the ID of that handler is given bywriteHandlerID.booleanThis will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
SockJSSocket
public SockJSSocket(io.vertx.ext.web.handler.sockjs.SockJSSocket delegate) Create a new instance ofSockJSSocketdelegating to the given (non-null) instance ofSockJSSocket. -
SockJSSocket
-
-
Method Details
-
getDelegate
public io.vertx.ext.web.handler.sockjs.SockJSSocket getDelegate()Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMutinyDelegate- Specified by:
getDelegatein interfaceReadStream<io.vertx.core.buffer.Buffer>- Specified by:
getDelegatein interfaceStreamBase- Specified by:
getDelegatein interfaceWriteStream<io.vertx.core.buffer.Buffer>- Returns:
- the delegate instance
-
write
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
writein interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
SockJSSocket.write(Buffer)
-
writeAndAwait
public void writeAndAwait(io.vertx.core.buffer.Buffer data) Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely 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 aRuntimeException).- See Also:
-
SockJSSocket.write(Buffer)
-
writeAndForget
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
SockJSSocket.write(Buffer)
-
write
Write aStringto the socket, encoded in UTF-8.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
data- the string to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
SockJSSocket.write(String)
-
writeAndAwait
Write aStringto the socket, encoded in UTF-8.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely 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 aRuntimeException).- Parameters:
data- the string to write- See Also:
-
SockJSSocket.write(String)
-
writeAndForget
Write aStringto the socket, encoded in UTF-8.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
data- the string to write- Returns:
- The current instance to chain operations if needed.
- See Also:
-
SockJSSocket.write(String)
-
end
Callclose().Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
endin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
SockJSSocket.end()
-
endAndAwait
public void endAndAwait()Callclose().Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely 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 aRuntimeException).- See Also:
-
SockJSSocket.end()
-
endAndForget
- Returns:
- The current instance to chain operations if needed.
- See Also:
-
SockJSSocket.end()
-
end
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
endin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
data- the data to write- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
WriteStream.end(T)
-
endAndAwait
public void endAndAwait(io.vertx.core.buffer.Buffer data) Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely 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 aRuntimeException).- Parameters:
data- the data to write- See Also:
-
WriteStream.end(T)
-
endAndForget
Same asend()but writes some data to the stream before ending.Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
data- the data to write- Returns:
- The current instance to chain operations if needed.
- See Also:
-
WriteStream.end(T)
-
pipeTo
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<io.vertx.core.buffer.Buffer> dst) Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Specified by:
pipeToin interfaceReadStream<io.vertx.core.buffer.Buffer>- Parameters:
dst- the destination write stream- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
io.vertx.ext.web.handler.sockjs.SockJSSocket#pipeTo(WriteStream)
-
pipeToAndAwait
Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely 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 aRuntimeException).- Parameters:
dst- the destination write stream- See Also:
-
io.vertx.ext.web.handler.sockjs.SockJSSocket#pipeTo(WriteStream)
-
pipeToAndForget
Pipe thisReadStreamto theWriteStream.Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
dst- the destination write stream- Returns:
- The current instance to chain operations if needed.
- See Also:
-
io.vertx.ext.web.handler.sockjs.SockJSSocket#pipeTo(WriteStream)
-
exceptionHandler
Description copied from interface:ReadStreamSet an exception handler on the read stream.- Specified by:
exceptionHandlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Specified by:
exceptionHandlerin interfaceStreamBase- Specified by:
exceptionHandlerin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
handler- the exception handler. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-
handler
Description copied from interface:ReadStreamSet a data handler. As data is read, the handler will be called with the data.- Specified by:
handlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
pause
Description copied from interface:ReadStreamPause theReadStream, it sets the buffer infetchmode and clears the actual demand.While it's paused, no data will be sent to the data
handler.- Specified by:
pausein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
resume
Description copied from interface:ReadStreamResume reading, and sets the buffer inflowingmode. If theReadStreamhas been paused, reading will recommence on it.- Specified by:
resumein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
fetch
Description copied from interface:ReadStreamFetch the specifiedamountof elements. If theReadStreamhas been paused, reading will recommence with the specifiedamountof items, otherwise the specifiedamountwill be added to the current stream demand.- Specified by:
fetchin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
Description copied from interface:ReadStreamSet an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.- Specified by:
endHandlerin interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a reference to this, so the API can be used fluently
-
closeHandler
-
setWriteQueueMaxSize
Description copied from interface:WriteStreamSet the maximum size of the write queue tomaxSize. You will still be able to write to the stream even if there is more thanmaxSizeitems in the write queue. This is used as an indicator by classes such asPipeto provide flow control. The value is defined by the implementation of the stream, e.g in bytes for aNetSocket, etc...- Specified by:
setWriteQueueMaxSizein interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
maxSize- the max size of the write stream- Returns:
- a reference to this, so the API can be used fluently
-
drainHandler
Description copied from interface:WriteStreamSet 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. SeePipefor 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.- Specified by:
drainHandlerin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Parameters:
handler- the handler. Can benull.- Returns:
- a reference to this, so the API can be used fluently
-
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
public void close()Close it -
close
Close it giving a status code and reason. Only Applicable to RawWebSocket will downgrade to plain close for other transports. -
remoteAddress
public io.vertx.core.net.SocketAddress remoteAddress()Return the remote address for this socket -
localAddress
public io.vertx.core.net.SocketAddress localAddress()Return the local address for this socket -
headers
public io.vertx.core.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
Return the URI corresponding to the last request for this socket or the websocket handshake -
routingContext
- Returns:
- the Vert.x-Web RoutingContext corresponding to this socket
-
webSession
- Returns:
- the Vert.x-Web session corresponding to this socket. Can be
null.
-
webUser
- Returns:
- the Vert.x-Web user corresponding to this socket. Can be
null.
-
writeQueueFull
public boolean writeQueueFull()This will returntrueif there are more bytes in the write queue than the value set usingsetWriteQueueMaxSize(int)- Specified by:
writeQueueFullin interfaceWriteStream<io.vertx.core.buffer.Buffer>- Returns:
trueif write queue is full
-
pipe
Pause this stream and return aPipeto transfer the elements of this stream to a destinationWriteStream. The stream will be resumed when the pipe will be wired to aWriteStream.- Specified by:
pipein interfaceReadStream<io.vertx.core.buffer.Buffer>- Returns:
- a pipe
-
newInstance
Creates a new instance of theSockJSSocket. -
hashCode
public int hashCode() -
equals
-
toString
-
toMulti
@CheckReturnValue public io.smallrye.mutiny.Multi<io.vertx.core.buffer.Buffer> toMulti() -
toBlockingIterable
-
toBlockingStream
-
toSubscriber
Converts the current write stream to a subscriber.
-