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\Pipe to pipe 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

Same as @see \io\vertx\jphp\core\streams\WriteStream::end but with an <code>handler</code> called when the operation completes

end( $arg0,  $arg1 = null) : void

param $handler [callable] end($handler)

Same as but with an handler called when the operation completes

param $data [mixed] param $handler [callable] end($data, $handler)

Arguments

$arg0

callable | mixed

$arg1

callable

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

Same as but with an <code>handler</code> called when the operation completes

write( $arg0,  $arg1) : void

Arguments

$arg0

mixed

$arg1

callable

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