private function runCommand($arguments, ConnectionInterface $connection)
    {
        try {

            $commandClass = array_shift($arguments);

            if (null !== $this->getLogger()) {
                $this->log(
                    'Command from ' . $connection->getRemoteAddress() .
                    ": [$commandClass] " .
                    join(', ', array_map('json_encode', $arguments))
                );
            }


            if (isset($this->commands[$commandClass])) {
                $command = $this->commands[$commandClass];
            } else {

                if (!class_exists($commandClass)) {
                    throw new \RuntimeException("Command class `$commandClass` does not found.");
                }

                $command = new $commandClass($this);

                if (!$command instanceof Command\CommandInterface) {
                    throw new \RuntimeException("Every command must implement Command\\CommandInterface.");
                }

                $this->commands[$commandClass] = $command;
            }

            $result = $command->run($arguments, $connection);
            $result = [self::RESULT, $result];

        } catch (\Exception $e) {

            $result = [self::EXCEPTION, get_class($e), $e->getMessage()];
            $this->log('Exception: ' . $e->getMessage());

        }

        $connection->write(json_encode($result) . self::END_OF_RESULT);
    }