/** * @param string $event * @param callable $callback */ protected function setEventListener($event, callable $callback) { if ($this->socket !== null) { $this->socket->on($event, $callback); } }
/** * @param NetworkComponentInterface $component * @param SocketListenerInterface $socket */ public function __construct(SocketListenerInterface $socket, NetworkComponentInterface $component = null) { $this->socket = $socket; $this->component = $component === null ? new NullServer() : $component; $socket->on('connect', [$this, 'handleConnect']); }