src/Bunny/Async/Client.php
protected function flushWriteBuffer()
    {
        if ($this->flushWriteBufferPromise) {
            return $this->flushWriteBufferPromise;

        } else {
            $deferred = new Promise\Deferred();

            $this->eventLoop->addWriteStream($this->getStream(), function ($stream) use ($deferred) {
                try {
                    $this->write();

                    if ($this->writeBuffer->isEmpty()) {
                        $this->eventLoop->removeWriteStream($stream);
                        $this->flushWriteBufferPromise = null;
                        $deferred->resolve(true);
                    }

                } catch (\Exception $e) {
                    $this->eventLoop->removeWriteStream($stream);
                    $this->flushWriteBufferPromise = null;
                    $deferred->reject($e);
                }
            });

            return $this->flushWriteBufferPromise = $deferred->promise();
        }
    }
protected function flushWriteBuffer()
    {
        if ($this->flushWriteBufferPromise) {
            return $this->flushWriteBufferPromise;

        } else {
            $deferred = new Promise\Deferred();

            $this->eventLoop->addWriteStream($this->getStream(), function ($stream) use ($deferred) {
                try {
                    $this->write();

                    if ($this->writeBuffer->isEmpty()) {
                        $this->eventLoop->removeWriteStream($stream);
                        $this->flushWriteBufferPromise = null;
                        $deferred->resolve(true);
                    }

                } catch (\Exception $e) {
                    $this->eventLoop->removeWriteStream($stream);
                    $this->flushWriteBufferPromise = null;
                    $deferred->reject($e);
                }
            });

            return $this->flushWriteBufferPromise = $deferred->promise();
        }
    }
protected function flushWriteBuffer ( ) { if ( $ this -> flushWriteBufferPromise ) { return $ this -> flushWriteBufferPromise ; } else { $ deferred = new Promise \ Deferred ( ) ; $ this -> eventLoop -> addWriteStream ( $ this -> getStream ( ) , function ( $ stream ) use ( $ deferred ) { try { $ this -> write ( ) ; if ( $ this -> writeBuffer -> isEmpty ( ) ) { $ this -> eventLoop -> removeWriteStream ( $ stream ) ; $ this -> flushWriteBufferPromise = null ; $ deferred -> resolve ( true ) ; } } catch ( \ Exception $ e ) { $ this -> eventLoop -> removeWriteStream ( $ stream ) ; $ this -> flushWriteBufferPromise = null ; $ deferred -> reject ( $ e ) ; } } ) ; return $ this -> flushWriteBufferPromise = $ deferred -> promise ( ) ; } }
Asynchronously sends buffered data over the wire.

- Calls {@link eventLoops}'s addWriteStream() with client's stream.
- Consecutive calls will return the same instance of promise.

@return Promise\PromiseInterface
Asynchronously sends buffered data over the wire .