Calls a protocol

@param *string $protocol In the form of protocol://event
@param mixed   ...$args

@return Base
169260
public function triggerProtocol(string $protocol, ...$args)
    {
        list($protocol, $name) = explode('://', $protocol, 2);

        //if it's not a registered protocol
        if (!isset($this->protocols[$protocol])) {
            //oops?
            return $this;
        }

        //get the protocol
        $protocol = $this->protocols[$protocol];

        //we should deal with strings
        //then callables respectively
        //to allow overriding

        //they can call a class
        if (is_string($protocol) && strpos($protocol, '@') !== false) {
            return $this->triggerController($protocol, $name, ...$args);
        }

        //late binding ?
        if ($protocol instanceof Closure) {
            $protocol = $this->bindCallback($protocol);
        }

        if (is_callable($protocol)) {
            //call the protocol
            call_user_func($protocol, $name, ...$args);
        }

        //we can only deal with callable and strings
        //we don't want to throw an error
        //because it could just be a pseudo
        //placeholder
        return $this;
    }
1257700
public static function call($cb, array $args = [])
    {
        $ret = null;
        if (\is_object($cb) || (\is_string($cb) && \function_exists($cb))) {
            $ret = $cb(...$args);
        } elseif (\is_array($cb)) {
            list($obj, $mhd) = $cb;
            $ret = \is_object($obj) ? $obj->$mhd(...$args) : $obj::$mhd(...$args);
        } else {
            if (SWOOLE_VERSION >= '4.0') {
                $ret = call_user_func_array($cb, $args);
            } else {
                $ret = \Swoole\Coroutine::call_user_func_array($cb, $args);
            }
        }

        return $ret;
    }
70166
public function createCalled(
        $callback,
        Arguments $arguments
    ): CalledEvent {
        return new CalledEvent(
            $this->sequencer->next(),
            $this->clock->time(),
            $callback,
            $arguments
        );
    }
948334
public function invokeWith($arguments = [])
    {
        if (!$arguments instanceof Arguments) {
            $arguments = new Arguments($arguments);
        }

        return $this->callParentMethod
            ->invoke($this->mock, $this->name, $arguments);
    }
599401
public function setProtocol($protocol) {

        if ( empty($protocol) || !in_array($protocol, $this->supported_protocols) ) throw new InvalidArgumentException('Invalid or unsupported RPC protocol');

        $this->protocol = $protocol;

        return $this;

    }
856291
static function execute(Base $base)
    {

        self::$_base = $base;
        //first we separate the parameters
        $request = isset($_REQUEST['route']) ? $_REQUEST['route'] : '/';

        if(strpos($request,'?') > 0) {
            $split = explode('?',$request);
            $request = $split[0];
        }

        self::$_attr = array_slice(explode('/', trim($request, '/')), 2);

        self::_run($request);

        return self::$callback;
    }
392337
public function triggerEvent($event, $args = [])
    {
        $dispatcher = $this->getDispatcher();

        if (!$dispatcher instanceof DispatcherInterface) {
            return null;
        }

        $args['mapper'] = $this;

        $event = $this->dispatcher->triggerEvent($event, $args);

        $innerListener = [$this, $event->getName()];

        if (!$event->isStopped() && method_exists($this, $event->getName())) {
            call_user_func($innerListener, $event);
        }

        return $event;
    }
389037
public function addProtocol($protocol)
    {
        if (!\in_array($protocol, [ApiDefinition::PROTOCOL_HTTP, ApiDefinition::PROTOCOL_HTTPS], true)) {
            throw new \InvalidArgumentException(\sprintf('"%s" is not a valid protocol', $protocol));
        }

        if (!\in_array($protocol, $this->protocols, true)) {
            $this->protocols[] = $protocol;
        }
    }
464413
public function addCall(string $method, array $arguments = []): Service
    {
        $this->calls[$method] = $arguments;

        return $this;
    }
301413
public function Invoke( $context, $provider, $args )
	{
		return is_null( $this->Delegate )
			? null
			: call_user_func( $this->Delegate, $context, $provider, $args );
	}
82931
public static function add(callable ...$args): callable
    {
        $sum = function ($x, ... $args) {
            $function = 0;
            foreach ($args as $arg) {
                $function += $arg($x);
            }
            return $function;
        };

        return function ($x) use ($args, $sum) {
            return $sum(...array_merge([$x], $args));
        };
    }
980302
static function entities(/* args... */) {

		$args = func_get_args();

		if (count($args) == 1 && is_array($args[0])) {
			$entities = $args[0];
		}
		else { # count != 1 || ! is_array(args[0])
			$entities = $args;
		}

		return \hlin\Protocol::instance()
			->entities($entities)
			->is('hlin.Check::entity Protocol');
	}
21324
function setProtocol($protocol)
    {
        if (!($protocol instanceof Swoole\IFace\Protocol))
        {
            throw new \Exception("The protocol is not instanceof \\Swoole\\IFace\\Protocol");
        }
        $this->protocol = $protocol;
        $protocol->server = $this;
    }
535325
public function triggerEvent($event, $args = [])
    {
        foreach ($this->dispatchers as $dispatcher) {
            $event = $dispatcher->triggerEvent($event, $args);
        }

        return $event;
    }
909445
public function trigger($name, ...$args)
    {
        //we should deal with strings
        //then callables respectively
        //to allow overriding
        if (is_string($name)) {
            //is it a protocol?
            if (strpos($name, '://') !== false) {
                return $this->triggerProtocol($name, ...$args);
            }

            //they can call a class
            if (strpos($name, '@') !== false) {
                return $this->triggerController($name, ...$args);
            }

            //unless it's a static call
            if (strpos($name, '::') !== false && is_callable($name)) {
                call_user_func_array($name, $args);
                return $this;
            }

            return $this->triggerEvent($name, ...$args);
        }

        if (is_callable($name)) {
            if ($name instanceof Closure) {
                $name = $this->bindCallback($name);
            }

            call_user_func_array($name, $args);
        }

        //we can only deal with callable and strings
        //we don't want to throw an error
        //because it could just be a pseudo
        //placeholder
        return $this;
    }
662743
public static function call(callable $callable, $args=null)
    {

        if (!is_array($args)) {
            $args = $args === null ? [] : [$args];
        }

        return static::callFast($callable, static::evaluateArgs($args));

    }
1367621
private function call($method, array $args)
    {
        $request = $this->rpcProtocol->encodeRequest($method, $args);

        $response = $this->transport->request($request);

        $response = $this->rpcProtocol->decodeValue($response);

        if ($response instanceof \Exception) {
            throw $response;
        }

        return $response;
    }