public function onHeartbeat() { if (isset($this->heartbeat_timer)) { $this->heartbeat_timer->cancel(); } $this->client->getLoop()->addTimer($this->client->getHeartbeatInterval(), function () { //Set a new timeout (2 sec seems reasonable) $this->heartbeat_timer = $this->client->getLoop()->addTimer(2, function () { $this->stream->close(); throw new ConnectionLostException(); }); $this->sendHeartbeat(); }); }
public function close() { $this->connector->close(); }