Top Description Fields Constructors Methods
io.vertx.core.datagram.impl

pack-priv Class PacketWriteStreamImpl

extends Object
implements WriteStream<Buffer>, Handler<AsyncResult<Void>>
Class Inheritance
All Implemented Interfaces
io.vertx.core.Handler, io.vertx.core.streams.WriteStream, io.vertx.core.streams.StreamBase
Imports
io.vertx.core.AsyncResult, .Future, .Handler, .Promise, io.vertx.core.buffer.Buffer, io.vertx.core.streams.WriteStream

A write stream for packets.
Author
Julien Viet

Field Summary

Modifier and TypeField and Description
private DatagramSocketImpl
private Handler<Throwable>
private final String
private final int

Constructor Summary

AccessConstructor and Description
pack-priv
PacketWriteStreamImpl(DatagramSocketImpl datagramSocket, int port, String host)

Method Summary

Modifier and TypeMethod and Description
public PacketWriteStreamImpl
public Future<Void>
end()

Overrides default io.vertx.core.streams.WriteStream.end.

Ends the stream.

public void
end(Handler<AsyncResult<Void>> handler)

Overrides default io.vertx.core.streams.WriteStream.end.

Implements io.vertx.core.streams.WriteStream.end.

Same as end() but with an handler called when the operation completes

public PacketWriteStreamImpl
public void
handle(AsyncResult<Void>
the event to handle
event
)

Implements io.vertx.core.Handler.handle.

Something has happened, so handle it.

public PacketWriteStreamImpl
setWriteQueueMaxSize(int
the max size of the write stream
maxSize
)

Implements io.vertx.core.streams.WriteStream.setWriteQueueMaxSize.

Set the maximum size of the write queue to maxSize.

public Future<Void>
write(Buffer
the data to write
data
)

Implements io.vertx.core.streams.WriteStream.write.

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Write some data to the stream.

public void
write(Buffer data, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.streams.WriteStream.write.

References Deprecated Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

Same as write(T) but with an handler called when the operation completes

public boolean
writeQueueFull()

Implements io.vertx.core.streams.WriteStream.writeQueueFull.

This will return true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

datagramSocketback to summary
private DatagramSocketImpl datagramSocket
exceptionHandlerback to summary
private Handler<Throwable> exceptionHandler
hostback to summary
private final String host
portback to summary
private final int port

Constructor Detail

PacketWriteStreamImplback to summary
pack-priv PacketWriteStreamImpl(DatagramSocketImpl datagramSocket, int port, String host)

Method Detail

drainHandlerback to summary
public PacketWriteStreamImpl drainHandler(Handler<Void> handler)
Annotations
@Override
endback to summary
public Future<Void> end()

Overrides default io.vertx.core.streams.WriteStream.end.

Doc from io.vertx.core.streams.WriteStream.end.

Ends the stream.

Once the stream has ended, it cannot be used any more.

Returns:Future<Void>

a future completed with the result

Annotations
@Override
endback to summary
public void end(Handler<AsyncResult<Void>> handler)

Overrides default io.vertx.core.streams.WriteStream.end.

Implements io.vertx.core.streams.WriteStream.end.

Doc from io.vertx.core.streams.WriteStream.end.

Same as end() but with an handler called when the operation completes

Annotations
@Override
exceptionHandlerback to summary
public PacketWriteStreamImpl exceptionHandler(Handler<Throwable> handler)
Annotations
@Override
handleback to summary
public void handle(AsyncResult<Void> event)

Implements io.vertx.core.Handler.handle.

Doc from io.vertx.core.Handler.handle.

Something has happened, so handle it.

Parameters
event:AsyncResult<Void>

the event to handle

Annotations
@Override
setWriteQueueMaxSizeback to summary
public PacketWriteStreamImpl setWriteQueueMaxSize(int maxSize)

Implements io.vertx.core.streams.WriteStream.setWriteQueueMaxSize.

Doc from io.vertx.core.streams.WriteStream.setWriteQueueMaxSize.

Set the maximum size of the write queue to 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 io.vertx.core.net.NetSocket, etc...

Parameters
maxSize:int

the max size of the write stream

Returns:PacketWriteStreamImpl

a reference to this, so the API can be used fluently

Annotations
@Override
writeback to summary
public Future<Void> write(Buffer data)

Implements io.vertx.core.streams.WriteStream.write.

Doc from io.vertx.core.streams.WriteStream.write.

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Write some data to the stream.

The data is usually put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the writeQueueFull method before writing. This is done automatically if using a Pipe.

When the data is moved from the queue to the actual medium, the returned Future will be completed with the write result, e.g the future is succeeded when a server HTTP response buffer is written to the socket and failed if the remote client has closed the socket while the data was still pending for write.

Parameters
data:Buffer

the data to write

Returns:Future<Void>

a future completed with the write result

Annotations
@Override
writeback to summary
public void write(Buffer data, Handler<AsyncResult<Void>> handler)

Implements io.vertx.core.streams.WriteStream.write.

Doc from io.vertx.core.streams.WriteStream.write.

References Deprecated

Buffer is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Same as write(T) but with an handler called when the operation completes

Annotations
@Override
writeQueueFullback to summary
public boolean writeQueueFull()

Implements io.vertx.core.streams.WriteStream.writeQueueFull.

Doc from io.vertx.core.streams.WriteStream.writeQueueFull.

This will return true if there are more bytes in the write queue than the value set using setWriteQueueMaxSize

Returns:boolean

true if write queue is full

Annotations
@Override