WriteStream

Represents a stream of data that can be written to.

Any class that implements this interface can be used by a @see \io\vertx\jphp\core\streams\Pump to pump data from a ReadStream to it.

package

Default

Methods

__construct

__construct() 

Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See @see \io\vertx\jphp\core\streams\Pump for an example of this being used.

drainHandler( $arg0) : $this

The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to maxSize / 2.

Arguments

$arg0

callable

Response

$this

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

Ends the stream.

end( $arg0 = null) : void

Once the stream has ended, it cannot be used any more. end() Same as @see \io\vertx\jphp\core\streams\WriteStream::end but writes some data to the stream before ending. param $t [mixed] end($t)

Arguments

$arg0

mixed

Set an exception handler on the write stream.

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

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

Set the maximum size of the write queue to <code>maxSize</code>. You will still be able to write to the stream even if there is more than <code>maxSize</code> items in the write queue. This is used as an indicator by classes such as <code>Pump</code> to provide flow control.

setWriteQueueMaxSize( $arg0) : $this

The value is defined by the implementation of the stream, e.g in bytes for a

see \io\vertx\jphp\core\net\NetSocket,

the number of @see \io\vertx\jphp\core\eventbus\Message for a

\io\vertx\jphp\core\eventbus\MessageProducer,

etc...

Arguments

$arg0

integer

Response

$this

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

Write some data to the stream. The data is 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 @see \io\vertx\jphp\core\streams\WriteStream::writeQueueFull method before writing. This is done automatically if using a @see \io\vertx\jphp\core\streams\Pump.

write( $arg0) : $this

Arguments

$arg0

mixed

Response

$this

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

This will return <code>true</code> if there are more bytes in the write queue than the value set using @see \io\vertx\jphp\core\streams\WriteStream::setWriteQueueMaxSize

writeQueueFull() : boolean

Response

boolean

true if write queue is full