public class NetSocketImpl extends ConnectionBase implements NetSocketInternal
chctx, CLOSED_EXCEPTION, context, vertx, voidPromise| Constructor and Description |
|---|
NetSocketImpl(VertxInternal vertx,
io.netty.channel.ChannelHandlerContext channel,
ContextInternal context,
SSLHelper helper,
TCPMetrics metrics) |
NetSocketImpl(VertxInternal vertx,
io.netty.channel.ChannelHandlerContext channel,
SocketAddress remoteAddress,
ContextInternal context,
SSLHelper helper,
TCPMetrics metrics) |
| Modifier and Type | Method and Description |
|---|---|
NetSocketImpl |
closeHandler(Handler<Void> handler)
Set a handler that will be called when the NetSocket is closed
|
NetSocket |
drainHandler(Handler<Void> drainHandler)
Set a drain handler on the stream.
|
void |
end()
Calls
NetSocket.close() |
void |
end(Handler<AsyncResult<Void>> handler)
Calls
NetSocket.end(Handler) |
NetSocket |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
NetSocketImpl |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
NetSocket |
fetch(long amount)
Fetch the specified
amount of elements. |
protected void |
handleClosed() |
protected void |
handleInterestedOpsChanged() |
void |
handleMessage(Object msg) |
NetSocket |
handler(Handler<Buffer> dataHandler)
Set a data handler.
|
NetSocketInternal |
messageHandler(Handler<Object> handler)
Set a
handler on this socket to process the messages produced by this socket. |
TCPMetrics |
metrics() |
NetSocket |
pause()
Pause the
ReadStream, it sets the buffer in fetch mode and clears the actual demand. |
NetSocket |
resume()
Resume reading, and sets the buffer in
flowing mode. |
NetSocket |
sendFile(String filename,
long offset,
long length)
Tell the operating system to stream a file as specified by
filename directly from disk to the outgoing connection,
bypassing userspace altogether (where supported by the underlying operating system. |
NetSocket |
sendFile(String filename,
long offset,
long length,
Handler<AsyncResult<Void>> resultHandler)
Same as
NetSocket.sendFile(String, long, long) but also takes a handler that will be called when the send has completed or
a failure has occurred |
NetSocket |
setWriteQueueMaxSize(int maxSize)
Set the maximum size of the write queue to
maxSize. |
NetSocket |
upgradeToSsl(Handler<Void> handler)
Upgrade channel to use SSL/TLS.
|
NetSocket |
upgradeToSsl(String serverName,
Handler<Void> handler)
Upgrade channel to use SSL/TLS.
|
NetSocket |
write(Buffer data)
Write some data to the stream.
|
NetSocket |
write(Buffer message,
Handler<AsyncResult<Void>> handler)
Like
WriteStream.write(Object) but with an handler called when the message has been written
or failed to be written. |
NetSocket |
write(String str)
Write a
String to the connection, encoded in UTF-8. |
NetSocket |
write(String str,
Handler<AsyncResult<Void>> handler)
Same as
NetSocket.write(String) but with an handler called when the operation completes |
NetSocket |
write(String str,
String enc)
Write a
String to the connection, encoded using the encoding enc. |
NetSocket |
write(String str,
String enc,
Handler<AsyncResult<Void>> handler)
Same as
NetSocket.write(String, String) but with an handler called when the operation completes |
String |
writeHandlerID()
When a
NetSocket is created it automatically registers an event handler with the event bus, the ID of that
handler is given by writeHandlerID. |
NetSocketInternal |
writeMessage(Object message)
Write a message in the channel pipeline.
|
NetSocketInternal |
writeMessage(Object message,
Handler<AsyncResult<Void>> handler)
Like
NetSocketInternal.writeMessage(Object) but with an handler called when the message has been written
or failed to be written. |
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
addFuture, channel, channelFuture, channelHandlerContext, checkContext, close, close, doPause, doResume, doSetWriteQueueMaxSize, exceptionHandler, fail, flush, flush, getContext, handleException, handleIdle, handler, indicatedServerName, isNotWritable, isSsl, localAddress, metric, metric, peerCertificateChain, remoteAddress, remoteName, reportBytesRead, reportBytesWritten, sendFile, sslSession, supportsFileRegion, toPromise, writeToChannel, writeToChannelclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitchannelHandlerContextclose, close, indicatedServerName, isSsl, localAddress, peerCertificateChain, remoteAddress, sendFile, sendFile, sendFile, sendFile, sslSessionpipe, pipeTo, pipeToend, endpublic NetSocketImpl(VertxInternal vertx, io.netty.channel.ChannelHandlerContext channel, ContextInternal context, SSLHelper helper, TCPMetrics metrics)
public NetSocketImpl(VertxInternal vertx, io.netty.channel.ChannelHandlerContext channel, SocketAddress remoteAddress, ContextInternal context, SSLHelper helper, TCPMetrics metrics)
public TCPMetrics metrics()
metrics in class ConnectionBasepublic String writeHandlerID()
NetSocketNetSocket 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 connection. This allows you to write data to other connections which are owned by different event loops.
writeHandlerID in interface NetSocketpublic NetSocketInternal writeMessage(Object message)
NetSocketInternalwriteMessage in interface NetSocketInternalmessage - the message to write, it should be handled by one of the channel pipeline handlerspublic NetSocketInternal writeMessage(Object message, Handler<AsyncResult<Void>> handler)
NetSocketInternalNetSocketInternal.writeMessage(Object) but with an handler called when the message has been written
or failed to be written.writeMessage in interface NetSocketInternalpublic NetSocket write(Buffer data)
WriteStreamWriteStream.writeQueueFull() method before writing. This is done automatically if using a Pump.write in interface NetSocketwrite in interface WriteStream<Buffer>data - the data to writepublic NetSocket write(String str)
NetSocketString to the connection, encoded in UTF-8.public NetSocket write(String str, Handler<AsyncResult<Void>> handler)
NetSocketNetSocket.write(String) but with an handler called when the operation completespublic NetSocket write(String str, String enc)
NetSocketString to the connection, encoded using the encoding enc.public NetSocket write(String str, String enc, Handler<AsyncResult<Void>> handler)
NetSocketNetSocket.write(String, String) but with an handler called when the operation completespublic NetSocket write(Buffer message, Handler<AsyncResult<Void>> handler)
NetSocketWriteStream.write(Object) but with an handler called when the message has been written
or failed to be written.write in interface NetSocketwrite in interface WriteStream<Buffer>public NetSocket handler(Handler<Buffer> dataHandler)
ReadStreamhandler in interface NetSockethandler in interface ReadStream<Buffer>public NetSocketInternal messageHandler(Handler<Object> handler)
NetSocketInternalhandler on this socket to process the messages produced by this socket. The message can be
ByteBuf or other messages produced by channel pipeline handlers.
The handler should take care of releasing pooled / direct messages.
The handler replaces any NetSocket.handler(Handler) previously set.messageHandler in interface NetSocketInternalhandler - the handler to setpublic NetSocket pause()
ReadStreamReadStream, 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 NetSocketpause in interface ReadStream<Buffer>public NetSocket fetch(long amount)
ReadStreamamount 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 NetSocketfetch in interface ReadStream<Buffer>public NetSocket resume()
ReadStreamflowing mode.
If the ReadStream has been paused, reading will recommence on it.resume in interface NetSocketresume in interface ReadStream<Buffer>public NetSocket setWriteQueueMaxSize(int maxSize)
WriteStreammaxSize. 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 NetSocketsetWriteQueueMaxSize in interface WriteStream<Buffer>maxSize - the max size of the write streampublic boolean writeQueueFull()
WriteStreamtrue if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int)writeQueueFull in interface WriteStream<Buffer>public NetSocket endHandler(Handler<Void> endHandler)
NetSocketThis handler might be called after the close handler when the socket is paused and there are still buffers to deliver.
endHandler in interface NetSocketendHandler in interface ReadStream<Buffer>public NetSocket drainHandler(Handler<Void> drainHandler)
WriteStreamPump 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 NetSocketdrainHandler in interface WriteStream<Buffer>drainHandler - the handlerpublic NetSocket sendFile(String filename, long offset, long length)
NetSocketfilename directly from disk to the outgoing connection,
bypassing userspace altogether (where supported by the underlying operating system. This is a very efficient way to stream files.public NetSocket sendFile(String filename, long offset, long length, Handler<AsyncResult<Void>> resultHandler)
NetSocketNetSocket.sendFile(String, long, long) but also takes a handler that will be called when the send has completed or
a failure has occurredpublic NetSocketImpl exceptionHandler(Handler<Throwable> handler)
ReadStreamexceptionHandler in interface NetSocketexceptionHandler in interface ReadStream<Buffer>exceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<Buffer>exceptionHandler in class ConnectionBasehandler - the exception handlerpublic NetSocketImpl closeHandler(Handler<Void> handler)
NetSocketcloseHandler in interface NetSocketcloseHandler in class ConnectionBasehandler - the handlerpublic NetSocket upgradeToSsl(Handler<Void> handler)
NetSocketupgradeToSsl in interface NetSockethandler - the handler will be notified when it's upgradedpublic NetSocket upgradeToSsl(String serverName, Handler<Void> handler)
NetSocketupgradeToSsl in interface NetSocketserverName - the server namehandler - the handler will be notified when it's upgradedprotected void handleInterestedOpsChanged()
handleInterestedOpsChanged in class ConnectionBasepublic void end(Handler<AsyncResult<Void>> handler)
NetSocketNetSocket.end(Handler)end in interface NetSocketend in interface WriteStream<Buffer>public void end()
NetSocketNetSocket.close()end in interface NetSocketend in interface WriteStream<Buffer>protected void handleClosed()
handleClosed in class ConnectionBasepublic void handleMessage(Object msg)
handleMessage in class ConnectionBaseCopyright © 2020. All rights reserved.