PHPDaemon\Clients\Asterisk\Connection::command PHP Method

command() protected method

Sends arbitrary command
protected command ( string $packet, callable $cb, array $assertion = null )
$packet string A packet for sending by the connected client to Asterisk
$cb callable Callback called when response received
$assertion array If more events may follow as response this is a main part or full an action complete event indicating that all data has been sent
    protected function command($packet, $cb, $assertion = null)
    {
        if ($this->finished) {
            throw new ConnectionFinished();
        }
        if ($this->state !== self::CONN_STATE_HANDSHAKED_OK) {
            return;
        }
        $actionId = Daemon::uniqid();
        if (!is_callable($cb, true)) {
            $cb = false;
        }
        $this->callbacks[$actionId] = CallbackWrapper::wrap($cb);
        if ($assertion !== null) {
            $this->assertions[$actionId] = $assertion;
        }
        $this->write($packet);
        $this->write('ActionID: ' . $actionId . "\r\n\r\n");
    }