public class SockJSSocket extends Object implements ReadStream<Buffer>, WriteStream<Buffer>
The API is very similar to WebSocket
.
It implements both and
so it can be used with
Pump
to pump data with flow control.
NOTE: This class has been automatically generated from the
original
non RX-ified interface using Vert.x codegen.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<SockJSSocket> |
__TYPE_ARG |
Constructor and Description |
---|
SockJSSocket(Object delegate) |
SockJSSocket(SockJSSocket delegate) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close it
|
void |
close(int statusCode,
String reason)
Close it giving a status code and reason.
|
SockJSSocket |
closeHandler(Handler<Void> closeHandler) |
SockJSSocket |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
void |
end()
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
void |
end(Buffer data)
Same as but with an
handler called when the operation completes |
void |
end(Buffer data,
Handler<AsyncResult<Void>> handler)
Same as but with an
handler called when the operation completes |
void |
end(Handler<AsyncResult<Void>> handler)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
SockJSSocket |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
boolean |
equals(Object o) |
SockJSSocket |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
SockJSSocket |
fetch(long amount)
Fetch the specified
amount of elements. |
SockJSSocket |
getDelegate() |
SockJSSocket |
handler(Handler<Buffer> handler)
Set a data handler.
|
int |
hashCode() |
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
|
SocketAddress |
localAddress()
Return the local address for this socket
|
static SockJSSocket |
newInstance(SockJSSocket arg) |
SockJSSocket |
pause()
Pause the
ReadStream , it sets the buffer in fetch mode and clears the actual demand. |
Pipe<Buffer> |
pipe()
Pause this stream and return a to transfer the elements of this stream to a destination .
|
void |
pipeTo(WriteStream<Buffer> dst)
Pipe this
ReadStream to the WriteStream . |
void |
pipeTo(WriteStream<Buffer> dst,
Handler<AsyncResult<Void>> handler)
Pipe this
ReadStream to the WriteStream . |
SocketAddress |
remoteAddress()
Return the remote address for this socket
|
SockJSSocket |
resume()
Resume reading, and sets the buffer in
flowing mode. |
RoutingContext |
routingContext() |
Completable |
rxEnd()
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but with an handler called when the operation completes |
Completable |
rxEnd(Buffer data)
Same as but with an
handler called when the operation completes |
Completable |
rxPipeTo(WriteStream<Buffer> dst)
Pipe this
ReadStream to the WriteStream . |
Completable |
rxWrite(Buffer data)
Same as but with an
handler called when the operation completes |
Completable |
rxWrite(String data) |
SockJSSocket |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize . |
Flowable<Buffer> |
toFlowable() |
Observable<Buffer> |
toObservable() |
WriteStreamObserver<Buffer> |
toObserver() |
String |
toString() |
WriteStreamSubscriber<Buffer> |
toSubscriber() |
String |
uri()
Return the URI corresponding to the last request for this socket or the websocket handshake
|
Session |
webSession() |
User |
webUser() |
void |
write(Buffer data)
Same as but with an
handler called when the operation completes |
void |
write(Buffer data,
Handler<AsyncResult<Void>> handler)
Same as but with an
handler called when the operation completes |
void |
write(String data) |
void |
write(String data,
Handler<AsyncResult<Void>> handler) |
String |
writeHandlerID()
When a
SockJSSocket is created it can register an event handler with the event bus, the ID of that
handler is given by writeHandlerID . |
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int) |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
newInstance, newInstance
newInstance, newInstance
newInstance
public static final io.vertx.lang.rx.TypeArg<SockJSSocket> __TYPE_ARG
public SockJSSocket(SockJSSocket delegate)
public SockJSSocket(Object delegate)
public SockJSSocket getDelegate()
getDelegate
in interface ReadStream<Buffer>
getDelegate
in interface StreamBase
getDelegate
in interface WriteStream<Buffer>
public Observable<Buffer> toObservable()
toObservable
in interface ReadStream<Buffer>
public Flowable<Buffer> toFlowable()
toFlowable
in interface ReadStream<Buffer>
public WriteStreamObserver<Buffer> toObserver()
public WriteStreamSubscriber<Buffer> toSubscriber()
public Pipe<Buffer> pipe()
WriteStream
.pipe
in interface ReadStream<Buffer>
public void pipeTo(WriteStream<Buffer> dst, Handler<AsyncResult<Void>> handler)
ReadStream
to the WriteStream
.
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.
pipeTo
in interface ReadStream<Buffer>
dst
- the destination write streamhandler
- public void pipeTo(WriteStream<Buffer> dst)
ReadStream
to the WriteStream
.
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.
pipeTo
in interface ReadStream<Buffer>
dst
- the destination write streampublic Completable rxPipeTo(WriteStream<Buffer> dst)
ReadStream
to the WriteStream
.
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.
rxPipeTo
in interface ReadStream<Buffer>
dst
- the destination write streampublic void end(Handler<AsyncResult<Void>> handler)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesend
in interface WriteStream<Buffer>
handler
- public void end()
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesend
in interface WriteStream<Buffer>
public Completable rxEnd()
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completesrxEnd
in interface WriteStream<Buffer>
public void end(Buffer data, Handler<AsyncResult<Void>> handler)
handler
called when the operation completesend
in interface WriteStream<Buffer>
data
- handler
- public void end(Buffer data)
handler
called when the operation completesend
in interface WriteStream<Buffer>
data
- public Completable rxEnd(Buffer data)
handler
called when the operation completesrxEnd
in interface WriteStream<Buffer>
data
- public boolean writeQueueFull()
true
if there are more bytes in the write queue than the value set using setWriteQueueMaxSize(int)
writeQueueFull
in interface WriteStream<Buffer>
true
if write queue is fullpublic SockJSSocket exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface ReadStream<Buffer>
exceptionHandler
in interface StreamBase
exceptionHandler
in interface WriteStream<Buffer>
handler
- the exception handlerpublic SockJSSocket handler(Handler<Buffer> handler)
ReadStream
handler
in interface ReadStream<Buffer>
public SockJSSocket pause()
ReadStream
ReadStream
, it sets the buffer in fetch
mode and clears the actual demand.
While it's paused, no data will be sent to the data handler
.
pause
in interface ReadStream<Buffer>
public SockJSSocket resume()
ReadStream
flowing
mode.
If the ReadStream
has been paused, reading will recommence on it.resume
in interface ReadStream<Buffer>
public SockJSSocket fetch(long amount)
ReadStream
amount
of elements. If the ReadStream
has been paused, reading will
recommence with the specified amount
of items, otherwise the specified amount
will
be added to the current stream demand.fetch
in interface ReadStream<Buffer>
public SockJSSocket endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface ReadStream<Buffer>
public SockJSSocket closeHandler(Handler<Void> closeHandler)
public void write(String data, Handler<AsyncResult<Void>> handler)
public void write(String data)
public Completable rxWrite(String data)
public void write(Buffer data, Handler<AsyncResult<Void>> handler)
WriteStream
handler
called when the operation completeswrite
in interface WriteStream<Buffer>
public void write(Buffer data)
WriteStream
handler
called when the operation completeswrite
in interface WriteStream<Buffer>
public Completable rxWrite(Buffer data)
WriteStream
handler
called when the operation completesrxWrite
in interface WriteStream<Buffer>
public SockJSSocket setWriteQueueMaxSize(int maxSize)
WriteStream
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
Pipe
to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket
, etc...setWriteQueueMaxSize
in interface WriteStream<Buffer>
maxSize
- the max size of the write streampublic SockJSSocket drainHandler(Handler<Void> handler)
WriteStream
Pipe
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
.
drainHandler
in interface WriteStream<Buffer>
handler
- the handlerpublic String writeHandlerID()
SockJSSocket
is created it can register 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.
writeHandlerID
or null
if writeHandler
registration is disabled in SockJSHandlerOptions
public void close()
public void close(int statusCode, String reason)
statusCode
- reason
- public SocketAddress remoteAddress()
public SocketAddress localAddress()
public MultiMap headers()
public String uri()
public RoutingContext routingContext()
public Session webSession()
public User webUser()
public static SockJSSocket newInstance(SockJSSocket arg)
Copyright © 2023 Eclipse. All rights reserved.