Beispiel #1
0
 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();
     });
 }
Beispiel #2
0
 public function close()
 {
     $this->connector->close();
 }