Example #1
0
 private function clearTimeoutWatcher()
 {
     if ($this->timeoutWatcherId !== null) {
         $this->logger->log(Level::DEBUG, "Cancelling timeout watcher #{$this->timeoutWatcherId}");
         cancel($this->timeoutWatcherId);
         $this->timeoutWatcherId = null;
     }
 }
Example #2
0
 private function closeSocket()
 {
     cancel($this->readWatcher);
     cancel($this->writeWatcher);
     $this->readWatcher = null;
     $this->writeWatcher = null;
     $this->parser->reset();
     $this->outputBuffer = "";
     $this->outputBufferLength = 0;
     if (is_resource($this->socket)) {
         @fclose($this->socket);
     }
     foreach ($this->handlers["close"] as $handler) {
         $handler();
     }
 }
Example #3
0
 /**
  * Shut down the mutex client.
  *
  * Be sure to release all locks you acquired before,
  * so other clients will be able to acquire them.
  *
  * @return Promise
  */
 public function shutdown() : Promise
 {
     cancel($this->watcher);
     $promises = [$this->std->close()];
     foreach ($this->busyConnections as $connection) {
         $promises[] = $connection->close();
     }
     foreach ($this->readyConnections as list($time, $connection)) {
         $promises[] = $connection->close();
     }
     return all($promises);
 }
Example #4
0
 private static function onEmptyWrite($state)
 {
     if (!\is_resource($state->socket) || @\feof($state->socket)) {
         $state->isDead = true;
         amp\cancel($state->writeWatcherId);
         foreach ($state->writeOperations as $op) {
             $op->promisor->succeed($op->bytesWritten);
         }
         $state->writeOperations = [];
     }
 }
Example #5
0
 private function removeScheduledActionsForUnapprovedRoom(Identifier $identifier)
 {
     foreach ($this->timerWatchers[$identifier->getIdentString()] ?? [] as $watcherId) {
         cancel($watcherId);
     }
     unset($this->timerWatchers[$identifier->getIdentString()]);
 }
Example #6
0
 public function disableForRoom(ChatRoom $room, bool $persist = false)
 {
     if (!$this->watchers) {
         return;
     }
     foreach ($this->watchers as $key => $id) {
         cancel($id);
     }
 }
Example #7
0
File: Server.php Project: lt/socket
 /**
  * The server will automatically stop listening if this object
  * is garbage collected. However, socket clients accepted by the
  * server will not be closed just because the server is unloaded.
  * Accepted clients must be manually closed or garbage collected.
  */
 public function __destruct()
 {
     amp\cancel($this->state->watcherId);
 }
Example #8
0
 public function __destruct()
 {
     cancel($this->repeatTimer);
 }