src/Bunny/Async/Client.php
public function onHeartbeat()
    {
        $now = microtime(true);
        $nextHeartbeat = ($this->lastWrite ?: $now) + $this->options["heartbeat"];

        if ($now >= $nextHeartbeat) {
            $this->writer->appendFrame(new HeartbeatFrame(), $this->writeBuffer);
            $this->flushWriteBuffer()->done(function () {
                $this->heartbeatTimer = $this->eventLoop->addTimer($this->options["heartbeat"], [$this, "onHeartbeat"]);
            });

        } else {
            $this->heartbeatTimer = $this->eventLoop->addTimer($nextHeartbeat - $now, [$this, "onHeartbeat"]);
        }
    }
public function onHeartbeat()
    {
        $now = microtime(true);
        $nextHeartbeat = ($this->lastWrite ?: $now) + $this->options["heartbeat"];

        if ($now >= $nextHeartbeat) {
            $this->writer->appendFrame(new HeartbeatFrame(), $this->writeBuffer);
            $this->flushWriteBuffer()->done(function () {
                $this->heartbeatTimer = $this->eventLoop->addTimer($this->options["heartbeat"], [$this, "onHeartbeat"]);
            });

        } else {
            $this->heartbeatTimer = $this->eventLoop->addTimer($nextHeartbeat - $now, [$this, "onHeartbeat"]);
        }
    }
public function onHeartbeat ( ) { $ now = microtime ( true ) ; $ nextHeartbeat = ( $ this -> lastWrite ? : $ now ) + $ this -> options [ "heartbeat" ] ; if ( $ now >= $ nextHeartbeat ) { $ this -> writer -> appendFrame ( new HeartbeatFrame ( ) , $ this -> writeBuffer ) ; $ this -> flushWriteBuffer ( ) -> done ( function ( ) { $ this -> heartbeatTimer = $ this -> eventLoop -> addTimer ( $ this -> options [ "heartbeat" ] , [ $ this , "onHeartbeat" ] ) ; } ) ; } else { $ this -> heartbeatTimer = $ this -> eventLoop -> addTimer ( $ nextHeartbeat - $ now , [ $ this , "onHeartbeat" ] ) ; } }
Callback when heartbeat timer timed out.
Callback when heartbeat timer timed out .