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 |
drainHandler(Handler<Void> handler)
Set a drain handler on the stream.
|
void |
end()
|
void |
end(Buffer data)
Same as
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but writes some data to the stream before ending. |
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.
|
ReadStream<Buffer> |
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)
Like
ReadStream.pipeTo(io.vertx.reactivex.core.streams.WriteStream<T>) but with no completion handler. |
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. |
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) |
SockJSSocket |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize . |
Flowable<Buffer> |
toFlowable() |
Observable<Buffer> |
toObservable() |
<any> |
toObserver() |
String |
toString() |
<any> |
toSubscriber() |
String |
uri()
Return the URI corresponding to the last request for this socket or the websocket handshake
|
Session |
webSession() |
User |
webUser() |
SockJSSocket |
write(Buffer data)
Write some data to the stream.
|
SockJSSocket |
write(Buffer data,
Handler<AsyncResult<Void>> handler)
Same as but with an
handler called when the operation completes |
SockJSSocket |
write(String data)
Write a
String to the socket, encoded in UTF-8. |
SockJSSocket |
write(String data,
Handler<AsyncResult<Void>> handler) |
String |
writeHandlerID()
When a
SockJSSocket is created it automatically registers 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 <any> toObserver()
public <any> toSubscriber()
public 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 Completable rxEnd()
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but with an handler
called when the operation completespublic void end(Buffer data)
end(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but writes some data to the stream before ending.end
in interface WriteStream<Buffer>
data
- the data to writepublic void end(Buffer data, Handler<AsyncResult<Void>> handler)
handler
called when the operation completesend
in interface WriteStream<Buffer>
data
- handler
- public Completable rxEnd(Buffer data)
handler
called when the operation completesdata
- 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>
public ReadStream<Buffer> fetch(long amount)
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>
amount
- public Pipe<Buffer> pipe()
WriteStream
.pipe
in interface ReadStream<Buffer>
public void pipeTo(WriteStream<Buffer> dst)
ReadStream.pipeTo(io.vertx.reactivex.core.streams.WriteStream<T>)
but with no completion handler.pipeTo
in interface ReadStream<Buffer>
dst
- 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 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.
dst
- the destination write streampublic 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 endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface ReadStream<Buffer>
public SockJSSocket write(Buffer data)
WriteStream
WriteStream.writeQueueFull()
method before writing. This is done automatically if using a Pump
.write
in interface WriteStream<Buffer>
data
- the data to writepublic SockJSSocket write(String data)
String
to the socket, encoded in UTF-8.data
- the string to writepublic SockJSSocket write(String data, Handler<AsyncResult<Void>> handler)
public SockJSSocket write(Buffer data, Handler<AsyncResult<Void>> handler)
WriteStream
handler
called when the operation completeswrite
in interface WriteStream<Buffer>
public Completable rxWrite(Buffer data)
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
Pump
to provide flow control.
The value is defined by the implementation of the stream, e.g in bytes for a
NetSocket
, the number of Message
for a
MessageProducer
, etc...setWriteQueueMaxSize
in interface WriteStream<Buffer>
maxSize
- the max size of the write streampublic SockJSSocket drainHandler(Handler<Void> handler)
WriteStream
Pump
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 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.
public void end()
end
in interface WriteStream<Buffer>
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 Session webSession()
public User webUser()
public static SockJSSocket newInstance(SockJSSocket arg)
Copyright © 2023 Eclipse. All rights reserved.