public class NetSocketImpl extends ConnectionBase implements NetSocket
channel, closeHandler, context, exceptionHandler, metrics, vertx| Constructor and Description |
|---|
NetSocketImpl(VertxInternal vertx,
io.netty.channel.Channel channel,
ContextImpl context,
SSLHelper helper,
boolean client,
TCPMetrics metrics,
Object metric) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the connection
|
NetSocket |
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.
|
NetSocket |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
NetSocket |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
protected void |
handleClosed() |
protected void |
handleInterestedOpsChanged() |
NetSocket |
handler(Handler<Buffer> dataHandler)
Set a data handler.
|
boolean |
isSsl() |
SocketAddress |
localAddress() |
protected Object |
metric() |
NetSocket |
pause()
Pause the
ReadSupport. |
X509Certificate[] |
peerCertificateChain() |
SocketAddress |
remoteAddress() |
NetSocket |
resume()
Resume reading.
|
NetSocket |
sendFile(String filename)
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,
Handler<AsyncResult<Void>> resultHandler)
Same as
NetSocket.sendFile(String) but also takes a handler that will be called when the send has completed or
a failure has occurred |
protected void |
setMetric(Object metric) |
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 |
write(Buffer data)
Write some data to the stream.
|
NetSocket |
write(String str)
Write a
String to the connection, encoded in UTF-8. |
NetSocket |
write(String str,
String enc)
Write a
String to the connection, encoded using the encoding enc. |
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. |
boolean |
writeQueueFull()
This will return
true if there are more bytes in the write queue than the value set using WriteStream.setWriteQueueMaxSize(int) |
addFuture, checkContext, doPause, doResume, doSetWriteQueueMaxSize, endReadAndFlush, getContext, getPeerCertificateChain, handleException, isNotWritable, queueForWrite, reportBytesRead, reportBytesWritten, sendFile, startRead, supportsFileRegion, writeToChannelpublic NetSocketImpl(VertxInternal vertx, io.netty.channel.Channel channel, ContextImpl context, SSLHelper helper, boolean client, TCPMetrics metrics, Object metric)
protected void setMetric(Object metric)
protected Object metric()
metric 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 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, String enc)
NetSocketString to the connection, encoded using the encoding enc.public NetSocket handler(Handler<Buffer> dataHandler)
ReadStreamhandler in interface NetSockethandler in interface ReadStream<Buffer>public NetSocket pause()
ReadStreamReadSupport. While it's paused, no data will be sent to the dataHandlerpause in interface NetSocketpause in interface ReadStream<Buffer>public NetSocket resume()
ReadStreamReadSupport 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 bytes in the write queue. This is used as an indicator by classes such as
Pump to provide flow control.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)
ReadStreamendHandler in interface NetSocketendHandler in interface ReadStream<Buffer>public NetSocket drainHandler(Handler<Void> drainHandler)
WriteStreamPump for an example of this being used.drainHandler in interface NetSocketdrainHandler in interface WriteStream<Buffer>drainHandler - the handlerpublic NetSocket sendFile(String filename)
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, Handler<AsyncResult<Void>> resultHandler)
NetSocketNetSocket.sendFile(String) but also takes a handler that will be called when the send has completed or
a failure has occurredpublic SocketAddress remoteAddress()
remoteAddress in interface NetSocketremoteAddress in class ConnectionBasepublic SocketAddress localAddress()
localAddress in interface NetSocketlocalAddress in class ConnectionBasepublic NetSocket exceptionHandler(Handler<Throwable> handler)
ReadStreamexceptionHandler in interface NetSocketexceptionHandler in interface ReadStream<Buffer>exceptionHandler in interface StreamBaseexceptionHandler in interface WriteStream<Buffer>handler - the exception handlerpublic NetSocket closeHandler(Handler<Void> handler)
NetSocketcloseHandler in interface NetSockethandler - the handlerpublic void close()
ConnectionBaseclose in interface NetSocketclose in class ConnectionBasepublic NetSocket upgradeToSsl(Handler<Void> handler)
NetSocketupgradeToSsl in interface NetSockethandler - the handler will be notified when it's upgradedpublic boolean isSsl()
public X509Certificate[] peerCertificateChain() throws SSLPeerUnverifiedException
peerCertificateChain in interface NetSocketSSLPeerUnverifiedException - SSL peer's identity has not been verified.protected void handleInterestedOpsChanged()
handleInterestedOpsChanged in class ConnectionBaseprotected void handleClosed()
handleClosed in class ConnectionBaseCopyright © 2015. All Rights Reserved.