public function onData(string $data)
    {
        $data = trim($data);
        $this->log('->' . $data);
        $chunks = explode(' ', $data);
        $command = $chunks[0];
        unset($chunks[0]);
        $input = '';
        if (count($chunks) > 0) {
            $input = implode(' ', $chunks);
        }
        $input = trim($input);
        if ($this->node->getCommands()->has($command)) {
            $this
                ->node
                ->getCommands()
                ->get($command)
                ->handle($this, $input)
                ->then(function (array $lines) {
                    foreach ($lines as $line) {
                        $this->write($line);
                    }
                });
            return;
        }

        $list = implode(', ', $this->node->getCommands()->keys());
        $this->write(
            '# Unknown command. Try ' . substr_replace($list, ' or ', strrpos($list, ', '), 2)
        );
    }
public function onData(string $data)
    {
        $data = trim($data);
        $this->log('->' . $data);
        $chunks = explode(' ', $data);
        $command = $chunks[0];
        unset($chunks[0]);
        $input = '';
        if (count($chunks) > 0) {
            $input = implode(' ', $chunks);
        }
        $input = trim($input);
        if ($this->node->getCommands()->has($command)) {
            $this
                ->node
                ->getCommands()
                ->get($command)
                ->handle($this, $input)
                ->then(function (array $lines) {
                    foreach ($lines as $line) {
                        $this->write($line);
                    }
                });
            return;
        }

        $list = implode(', ', $this->node->getCommands()->keys());
        $this->write(
            '# Unknown command. Try ' . substr_replace($list, ' or ', strrpos($list, ', '), 2)
        );
    }
public function onData ( string $ data ) { $ data = trim ( $ data ) ; $ this -> log ( '->' . $ data ) ; $ chunks = explode ( ' ' , $ data ) ; $ command = $ chunks [ 0 ] ; unset ( $ chunks [ 0 ] ) ; $ input = '' ; if ( count ( $ chunks ) > 0 ) { $ input = implode ( ' ' , $ chunks ) ; } $ input = trim ( $ input ) ; if ( $ this -> node -> getCommands ( ) -> has ( $ command ) ) { $ this -> node -> getCommands ( ) -> get ( $ command ) -> handle ( $ this , $ input ) -> then ( function ( array $ lines ) { foreach ( $ lines as $ line ) { $ this -> write ( $ line ) ; } } ) ; return ; } $ list = implode ( ', ' , $ this -> node -> getCommands ( ) -> keys ( ) ) ; $ this -> write ( '# Unknown command. Try ' . substr_replace ( $ list , ' or ' , strrpos ( $ list , ', ' ) , 2 ) ) ; }
Handle a command call from the clients side

@param string $data
Handle a command call from the clients side