本文整理汇总了PHP中React\EventLoop\LoopInterface::removeReadStream方法的典型用法代码示例。如果您正苦于以下问题:PHP LoopInterface::removeReadStream方法的具体用法?PHP LoopInterface::removeReadStream怎么用?PHP LoopInterface::removeReadStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类React\EventLoop\LoopInterface
的用法示例。
在下文中一共展示了LoopInterface::removeReadStream方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: close
/**
*
*/
public function close()
{
$this->loop->removeReadStream($this->socket);
if (is_resource($this->socket)) {
fclose($this->socket);
}
$this->notifyCompleted();
}
示例2: del
/**
* Remove event listener from event loop.
*
* @param mixed $fd
* @param int $flag
* @return bool
*/
public function del($fd, $flag)
{
switch ($flag) {
case EventInterface::EV_READ:
return $this->_loop->removeReadStream($fd);
case EventInterface::EV_WRITE:
return $this->_loop->removeWriteStream($fd);
case EventInterface::EV_SIGNAL:
return $this->_loop->removeSignal($fd);
case EventInterface::EV_TIMER:
case EventInterface::EV_TIMER_ONCE:
return $this->_loop->cancelTimer($fd);
}
return false;
}
示例3: disconnect
/**
* Disconnects client from server.
*
* Calling disconnect() multiple times or if client is not connected will result in error.
*
* @param int $replyCode
* @param string $replyText
* @return Promise\PromiseInterface
*/
public function disconnect($replyCode = 0, $replyText = "")
{
if ($this->state !== ClientStateEnum::CONNECTED) {
return Promise\reject(new ClientException("Client is not connected."));
}
$this->state = ClientStateEnum::DISCONNECTING;
$promises = [];
if ($replyCode === 0) {
foreach ($this->channels as $channel) {
$promises[] = $channel->close();
}
}
if ($this->heartbeatTimer) {
$this->heartbeatTimer->cancel();
$this->heartbeatTimer = null;
}
return Promise\all($promises)->then(function () use($replyCode, $replyText) {
return $this->connectionClose($replyCode, $replyText, 0, 0);
})->then(function () {
$this->eventLoop->removeReadStream($this->getStream());
$this->closeStream();
$this->init();
return $this;
});
}
示例4: unregister
protected function unregister()
{
if (!$this->active) {
return;
}
$this->active = false;
$this->loop->removeReadStream($this->fd, [$this, 'handleEvent']);
}
示例5: testRemoveInvalid
public function testRemoveInvalid()
{
$stream = $this->createStream();
// remove a valid stream from the event loop that was never added in the first place
$this->loop->removeReadStream($stream);
$this->loop->removeWriteStream($stream);
$this->loop->removeStream($stream);
}
示例6: close
/**
* close the inotifyHandler and clear all pending events (if any)
*/
public function close()
{
if ($this->inotifyHandler !== false) {
$this->loop->removeReadStream($this->inotifyHandler);
fclose($this->inotifyHandler);
$this->inotifyHandler = false;
$this->watchDescriptors = array();
}
}
示例7: cancel
/**
* Cancel an existing timer/stream watcher
*
* @param int $watcherId
*/
public function cancel($watcherId)
{
if (isset($this->watchers[$watcherId])) {
list($type, $data) = $this->watchers[$watcherId];
switch ($type) {
case self::WATCHER_TYPE_READ:
$this->reactor->removeReadStream($data);
break;
case self::WATCHER_TYPE_WRITE:
$this->reactor->removeWriteStream($data);
break;
case self::WATCHER_TYPE_TIMER:
$this->reactor->cancelTimer($data);
break;
}
}
unset($this->watchers[$watcherId], $this->disabledWatchers[$watcherId]);
}
示例8: process
public function process($stream, $loop)
{
$response = fgets($stream);
if ($response === false) {
$this->state = self::STATE_DISCONNECTED;
$this->onFailure->__invoke($this->record, "Error while reading data");
echo $this->errno . ': ' . $this->errstr . PHP_EOL;
return;
}
$code = intval(substr($response, 0, 3));
$sub = intval($response[4] . $response[6] . $response[8]);
if (($code === 220 || $code === 250) && $sub === 0) {
return;
}
if ($code === 250 && $sub === 210) {
$this->state = self::STATE_IDLE;
return;
}
if ($this->record === null) {
throw new LogicException("Email not set.");
}
if ($code === 250 && $sub === 215) {
$this->onSuccess->__invoke($this->record);
$this->state = self::STATE_IDLE;
} else {
if ($code === 452 && $sub === 453) {
$this->loop->removeReadStream($this->stream);
fclose($this->stream);
$this->onFailure->__invoke($this->record, "limit reached");
$this->state = self::STATE_DISCONNECTED;
} else {
$this->onFailure->__invoke($this->record, false);
while (substr($response, -7, 5) !== 'gsmtp') {
$response = fgets($stream);
}
$this->state = self::STATE_IDLE;
}
}
}
示例9: removeReadStream
/**
* Remove the read event listener for the given stream.
*
* @param stream $stream The PHP stream resource.
*/
public function removeReadStream($stream)
{
$this->emit('removeReadStream', [$stream]);
$this->loop->removeReadStream($stream);
}