protected function createListenServers(Server $server): void
    {
        $this->fire(ServerEvent::PORT_CREATE, $this);

        foreach ($this->attachedListeners as $name => $cb) {
            $info = '';

            if ($cb instanceof \Closure) {
                $port = $cb($server, $this);
            } else {
                /**
                 * @var ServerInterface       $this
                 * @var PortListenerInterface $cb
                 */
                $port = $cb->attachTo($this, $server);
            }

            if ($port) {
                $type = $port->type === SWOOLE_SOCK_TCP ? 'tcp' : 'udp';
                $info = "(<cyan>$type://{$port->host}:{$port->port}</cyan>)";
            }

            $this->log("Attach the port listen server <info>$name</info>$info to the main server");
        }

        $this->attachedListeners = []; // reset.
        $this->fire(ServerEvent::PORT_CREATED, [$this]);
    }
protected function createListenServers(Server $server): void
    {
        $this->fire(ServerEvent::PORT_CREATE, $this);

        foreach ($this->attachedListeners as $name => $cb) {
            $info = '';

            if ($cb instanceof \Closure) {
                $port = $cb($server, $this);
            } else {
                /**
                 * @var ServerInterface       $this
                 * @var PortListenerInterface $cb
                 */
                $port = $cb->attachTo($this, $server);
            }

            if ($port) {
                $type = $port->type === SWOOLE_SOCK_TCP ? 'tcp' : 'udp';
                $info = "(<cyan>$type://{$port->host}:{$port->port}</cyan>)";
            }

            $this->log("Attach the port listen server <info>$name</info>$info to the main server");
        }

        $this->attachedListeners = []; // reset.
        $this->fire(ServerEvent::PORT_CREATED, [$this]);
    }
protected function createListenServers ( Server $ server ) : void { $ this -> fire ( ServerEvent :: PORT_CREATE , $ this ) ; foreach ( $ this -> attachedListeners as $ name => $ cb ) { $ info = '' ; if ( $ cb instanceof \ Closure ) { $ port = $ cb ( $ server , $ this ) ; } else { /**
                 * @var ServerInterface       $this
                 * @var PortListenerInterface $cb
                 */ $ port = $ cb -> attachTo ( $ this , $ server ) ; } if ( $ port ) { $ type = $ port -> type === SWOOLE_SOCK_TCP ? 'tcp' : 'udp' ; $ info = "(<cyan>$type://{$port->host}:{$port->port}</cyan>)" ; } $ this -> log ( "Attach the port listen server <info>$name</info>$info to the main server" ) ; } $ this -> attachedListeners = [ ] ; // reset. $ this -> fire ( ServerEvent :: PORT_CREATED , [ $ this ] ) ; }
create Listen Port Servers
@param Server $server
create Listen Port Servers