Class SockJSSocket
- java.lang.Object
-
- io.vertx.mutiny.ext.web.handler.sockjs.SockJSSocket
-
- All Implemented Interfaces:
ReadStream<Buffer>
,StreamBase
,WriteStream<Buffer>
public class SockJSSocket extends Object implements 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 withPump
to pump data with flow control.original
non Mutiny-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<SockJSSocket>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description SockJSSocket(io.vertx.ext.web.handler.sockjs.SockJSSocket delegate)
SockJSSocket(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
close(int statusCode, String reason)
SockJSSocket
closeHandler(Runnable closeHandler)
SockJSSocket
drainHandler(Runnable handler)
io.smallrye.mutiny.Uni<Void>
end()
Same asWriteStream.end()
but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
end(Buffer data)
Same as but with anhandler
called when the operation completesVoid
endAndAwait()
Blocking variant ofWriteStream.end()
.Void
endAndAwait(Buffer data)
Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#end(T)
.void
endAndForget()
Variant ofWriteStream.end()
that ignores the result of the operation.void
endAndForget(Buffer data)
Variant ofio.vertx.mutiny.core.streams.WriteStream#end(T)
that ignores the result of the operation.SockJSSocket
endHandler(Runnable endHandler)
boolean
equals(Object o)
SockJSSocket
exceptionHandler(Consumer<Throwable> handler)
SockJSSocket
fetch(long amount)
io.vertx.ext.web.handler.sockjs.SockJSSocket
getDelegate()
SockJSSocket
handler(Consumer<Buffer> handler)
int
hashCode()
MultiMap
headers()
SocketAddress
localAddress()
static SockJSSocket
newInstance(io.vertx.ext.web.handler.sockjs.SockJSSocket arg)
SockJSSocket
pause()
Pipe<Buffer>
pipe()
io.smallrye.mutiny.Uni<Void>
pipeTo(WriteStream<Buffer> dst)
Pipe thisReadStream
to theWriteStream
.Void
pipeToAndAwait(WriteStream<Buffer> dst)
Blocking variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
.void
pipeToAndForget(WriteStream<Buffer> dst)
Variant ofReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
that ignores the result of the operation.SocketAddress
remoteAddress()
SockJSSocket
resume()
RoutingContext
routingContext()
SockJSSocket
setWriteQueueMaxSize(int maxSize)
Iterable<Buffer>
toBlockingIterable()
Stream<Buffer>
toBlockingStream()
io.smallrye.mutiny.Multi<Buffer>
toMulti()
String
toString()
WriteStreamSubscriber<Buffer>
toSubscriber()
String
uri()
Session
webSession()
User
webUser()
io.smallrye.mutiny.Uni<Void>
write(Buffer data)
Same as but with anhandler
called when the operation completesio.smallrye.mutiny.Uni<Void>
write(String data)
Void
writeAndAwait(Buffer data)
Blocking variant ofio.vertx.mutiny.core.streams.WriteStream#write(T)
.Void
writeAndAwait(String data)
void
writeAndForget(Buffer data)
Variant ofio.vertx.mutiny.core.streams.WriteStream#write(T)
that ignores the result of the operation.void
writeAndForget(String data)
String
writeHandlerID()
boolean
writeQueueFull()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<SockJSSocket> __TYPE_ARG
-
-
Constructor Detail
-
SockJSSocket
public SockJSSocket(io.vertx.ext.web.handler.sockjs.SockJSSocket delegate)
-
SockJSSocket
public SockJSSocket(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.ext.web.handler.sockjs.SockJSSocket getDelegate()
- Specified by:
getDelegate
in interfaceReadStream<Buffer>
- Specified by:
getDelegate
in interfaceStreamBase
- Specified by:
getDelegate
in interfaceWriteStream<Buffer>
-
toSubscriber
@CheckReturnValue public WriteStreamSubscriber<Buffer> toSubscriber()
-
end
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> end()
Description copied from interface:WriteStream
Same asWriteStream.end()
but with anhandler
called when the operation completesUnlike 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 interfaceWriteStream<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 ofWriteStream.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 interfaceWriteStream<Buffer>
- Returns:
- the Void instance produced by the operation.
-
endAndForget
public void endAndForget()
Description copied from interface:WriteStream
Variant ofWriteStream.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 fromWriteStream.end()
but you don't need to compose it with other operations.- Specified by:
endAndForget
in interfaceWriteStream<Buffer>
-
end
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> end(Buffer data)
Description copied from interface:WriteStream
Same as but with anhandler
called when the operation completesUnlike 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 interfaceWriteStream<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 ofio.vertx.mutiny.core.streams.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 interfaceWriteStream<Buffer>
- Returns:
- the Void instance produced by the operation.
-
endAndForget
public void endAndForget(Buffer data)
Description copied from interface:WriteStream
Variant ofio.vertx.mutiny.core.streams.WriteStream#end(T)
that ignores the result of the operation.This method subscribes on the result of
io.vertx.mutiny.core.streams.WriteStream#end(T)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromio.vertx.mutiny.core.streams.WriteStream#end(T)
but you don't need to compose it with other operations.- Specified by:
endAndForget
in interfaceWriteStream<Buffer>
-
writeQueueFull
public boolean writeQueueFull()
- Specified by:
writeQueueFull
in interfaceWriteStream<Buffer>
- Returns:
true
if write queue is full
-
pipe
public Pipe<Buffer> pipe()
- Specified by:
pipe
in interfaceReadStream<Buffer>
- Returns:
- a pipe
-
pipeTo
@CheckReturnValue public io.smallrye.mutiny.Uni<Void> pipeTo(WriteStream<Buffer> dst)
Description copied from interface:ReadStream
Pipe thisReadStream
to theWriteStream
.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 interfaceReadStream<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 ofReadStream.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 interfaceReadStream<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 ofReadStream.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 fromReadStream.pipeTo(io.vertx.mutiny.core.streams.WriteStream)
but you don't need to compose it with other operations.- Specified by:
pipeToAndForget
in interfaceReadStream<Buffer>
- Parameters:
dst
- the destination write stream
-
exceptionHandler
public SockJSSocket exceptionHandler(Consumer<Throwable> handler)
- Specified by:
exceptionHandler
in interfaceReadStream<Buffer>
- Specified by:
exceptionHandler
in interfaceStreamBase
- Specified by:
exceptionHandler
in interfaceWriteStream<Buffer>
- Parameters:
handler
- the exception handler- Returns:
-
handler
public SockJSSocket handler(Consumer<Buffer> handler)
- Specified by:
handler
in interfaceReadStream<Buffer>
- Returns:
-
pause
public SockJSSocket pause()
- Specified by:
pause
in interfaceReadStream<Buffer>
- Returns:
- a reference to this, so the API can be used fluently
-
resume
public SockJSSocket resume()
- Specified by:
resume
in interfaceReadStream<Buffer>
- Returns:
- a reference to this, so the API can be used fluently
-
fetch
public SockJSSocket fetch(long amount)
- Specified by:
fetch
in interfaceReadStream<Buffer>
- Returns:
- a reference to this, so the API can be used fluently
-
endHandler
public SockJSSocket endHandler(Runnable endHandler)
- Specified by:
endHandler
in interfaceReadStream<Buffer>
- Returns:
-
closeHandler
public SockJSSocket closeHandler(Runnable closeHandler)
-
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 anhandler
called when the operation completesUnlike 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 interfaceWriteStream<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 ofio.vertx.mutiny.core.streams.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 interfaceWriteStream<Buffer>
- Returns:
- the Void instance produced by the operation.
-
writeAndForget
public void writeAndForget(Buffer data)
Description copied from interface:WriteStream
Variant ofio.vertx.mutiny.core.streams.WriteStream#write(T)
that ignores the result of the operation.This method subscribes on the result of
io.vertx.mutiny.core.streams.WriteStream#write(T)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromio.vertx.mutiny.core.streams.WriteStream#write(T)
but you don't need to compose it with other operations.- Specified by:
writeAndForget
in interfaceWriteStream<Buffer>
-
setWriteQueueMaxSize
public SockJSSocket setWriteQueueMaxSize(int maxSize)
- Specified by:
setWriteQueueMaxSize
in interfaceWriteStream<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 interfaceWriteStream<Buffer>
- Parameters:
handler
- the handler- Returns:
-
writeHandlerID
public String writeHandlerID()
- Returns:
- the
writeHandlerID
ornull
ifwriteHandler
registration is disabled inSockJSHandlerOptions
-
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 interfaceReadStream<Buffer>
-
newInstance
public static SockJSSocket newInstance(io.vertx.ext.web.handler.sockjs.SockJSSocket arg)
-
-