/** * {@inheritdoc} */ public function create($resource, callable $callback) : SocketEventInterface { $id = (int) $resource; if (isset($this->sockets[$id])) { throw new ResourceBusyError('A socket event has already been created for this resource.'); } return $this->sockets[$id] = $this->factory->socket($this, $resource, $callback); }
/** * {@inheritdoc} */ public function create($resource, callable $callback) : SocketEventInterface { $id = (int) $resource; if (isset($this->events[$id])) { throw new ResourceBusyError('A poll has already been created for that resource.'); } $socket = $this->factory->socket($this, $resource, $callback); $event = $this->loop->io($resource, $this->type, $this->socketCallback, $socket); $event->stop(); $this->events[$id] = $event; return $socket; }