Process call

@param \Thruway\Session $session
@param \Thruway\Message\CallMessage $msg
@return boolean
774334
private function processCall(Session $session, CallMessage $msg)
    {
        if (!Utils::uriIsValid($msg->getProcedureName())) {
            $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.invalid_uri'));

            return;
        }

        if (!isset($this->procedures[$msg->getProcedureName()])) {
            $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.no_such_procedure'));

            return;
        }

        /* @var $procedure \Thruway\Procedure */
        $procedure = $this->procedures[$msg->getProcedureName()];

        $call = new Call($session, $msg, $procedure);

        $this->callInvocationIndex[$call->getInvocationRequestId()] = $call;
        $this->callRequestIndex[$msg->getRequestId()]               = $call;

        $keepIndex = $procedure->processCall($session, $call);

        if (!$keepIndex) {
            $this->removeCall($call);
        }
    }
972398
public function setMsisdnToSession($msisdn = '')
    {
        try {
            if (isset($this->objectSession) && $this->objectSession != NULL && is_object($this->objectSession)) {
                $this->logger->info(__FUNCTION__, 'Session with CI Session Class');
                if ($this->objectSession->has_userdata(self::SESSION_ID_CURRENT_USER_MSISDN)) {
                    $this->objectSession->unset_userdata(self::SESSION_ID_CURRENT_USER_MSISDN);
                }
                $this->objectSession->set_userdata(self::SESSION_ID_CURRENT_USER_MSISDN, $this->formatMsisdn($msisdn));
            } else {
                $this->logger->info(__FUNCTION__, 'Session with The Http Foundation Component');
                $this->session->replace([self::SESSION_ID_CURRENT_USER_MSISDN => $this->formatMsisdn($msisdn)]);
            }

            return TRUE;
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->logger->error(__FUNCTION__, $message);

            return FALSE;
        }
    }
284810
public function handleAuthenticateMessage(Realm $realm, Session $session, AuthenticateMessage $msg)
    {
        if ($session->getAuthenticationDetails() === null) {
            throw new \Exception('Authenticate with no previous auth details');
        }

        $authMethod = $session->getAuthenticationDetails()->getAuthMethod();

        // find the auth method
        foreach ($this->authMethods as $am => $authMethodInfo) {
            if ($authMethod == $am) {
                $this->onAuthenticateHandler($authMethod, $authMethodInfo, $realm, $session, $msg);
            }
        }
    }
1069607
protected function handlePONG($origin, $msg)
    {
        // :origin PONG origin target
        return $this->connection->dispatch(
            $this->makeEvent('!Pong', $origin, $msg[1])
        );
    }
1144639
public function message($msg)
    {
        foreach ($this as $client) {
            try {
                $this->execute(
                    "sendtextmessage",
                    array("msg" => $msg, "target" => $client, "targetmode" => Teamspeak::TEXTMSG_CLIENT)
                );
            } catch (TeamSpeak3_Adapter_ServerQuery_Exception $e) {
                /* ERROR_client_invalid_id */
                if ($e->getCode() != 0x0200) {
                    throw $e;
                }
            }
        }
    }
326838
public function chat(string $question, string $session)
    {
        return Request::exec(self::CHAT, compact('question', 'session'));
    }
774142
public function onWorkerHandlerMessage(ClientHandlerJobResponse $msg)
    {
        $this->workerHandlerReady = true;

        $requestId = $msg->getRequestId();
        if (isset($this->workerHandlerQueue[$requestId])) {
            unset($this->workerHandlerQueue[$requestId]);
        }

        $workerHandler = $msg->getWorkerHandlerId();
        $request       = $this->getRequest($requestId);

        if ($request === null) {
            $this->getLogger()->info(
                sprintf(
                    'WorkerHandler %s accepted request %s, but request is unknown.',
                    $workerHandler,
                    $requestId
                )
            );

            return;
        }

        $this->getLogger()->debug(
            sprintf(
                'Worker-handler %s accepted request: %s.',
                $workerHandler,
                $requestId
            )
        );

        $request->setWorkerHandlerId($workerHandler);
    }
1298526
public function handlesMessage(Message $msg)
    {
        $handledMsgCodes = [
            Message::MSG_CALL,
            Message::MSG_CANCEL,
            Message::MSG_REGISTER,
            Message::MSG_UNREGISTER,
            Message::MSG_YIELD,
            Message::MSG_INTERRUPT
        ];

        if (in_array($msg->getMsgCode(), $handledMsgCodes)) {
            return true;
        } elseif ($msg instanceof ErrorMessage && $msg->getErrorMsgCode() === Message::MSG_INVOCATION) {
            return true;
        } elseif ($msg instanceof ErrorMessage && $msg->getErrorMsgCode() === Message::MSG_INTERRUPT) {
            return true;
        } else {
            return false;
        }
    }
124628
private function log($msg)
    {
        $logger = $this->getConfig('logger');
        if (!$logger) return false;
        return call_user_func_array($logger, array($msg));
    }
1352296
public function sendMessage(Message $msg)
    {
        $this->lastOutboundActivity = microtime(true);
        $this->dispatchMessage($msg, 'Send');
    }
318978
public function handleHelloMessage(Realm $realm, Session $session, HelloMessage $msg)
    {
        $requestedMethods = $msg->getAuthMethods();
        $sentMessage      = false;

        // Go through the authmethods and try to send a response message
        foreach ($this->authMethods as $authMethod => $authMethodInfo) {
            if (in_array($authMethod, $requestedMethods)
                && (in_array($realm->getRealmName(), $authMethodInfo['auth_realms'])
                    || in_array("*", $authMethodInfo['auth_realms']))
            ) {
                $this->onHelloAuthHandler($authMethod, $authMethodInfo, $realm, $session, $msg);
                $sentMessage = true;
            }
        }

        //If we already replied with a message, we don't have to do anything else
        if ($sentMessage) {
            return;
        }

        // If no authentication providers are registered for this realm send an abort message
        if ($this->realmHasAuthProvider($realm->getRealmName())) {
            $session->abort(new \stdClass(), 'wamp.error.not_authorized');

            return;
        }

        //If we've gotten this far, it means that the user needs to be Logged in as anonymous
        $session->setAuthenticationDetails(AuthenticationDetails::createAnonymous());

        $details = new \stdClass();

        $session->sendMessage(new WelcomeMessage($session->getSessionId(), $details));
        $session->setAuthenticated(true);

    }
620893
public function ask($msg = '', $default = null)
	{
		$value = parent::ask($msg, $default);

		if (is_null($value))
		{
			return $value;
		}

		$value = strtolower($value);

		if (in_array($value, $this->trueAlias))
		{
			return true;
		}
		elseif (in_array($value, $this->falseAlias))
		{
			return false;
		}

		return $default;
	}
979408
protected function success($msg = '', $url = '', $data = '', $wait = 3)
    {
        return $this->jump(1, $msg, $url, $data, $wait);
    }
598197
private function processMessage(Realm $realm, Session $session, Message $msg)
    {
        if ($session->isAuthenticated()) {
            throw new \Exception('Message sent to authentication manager for already authenticated session.');
        }

        // trusted transports do not need any authentication
        if ($session->getTransport()->isTrusted()) {
            $authDetails = new AuthenticationDetails();
            $authDetails->setAuthMethod('internalClient');
            $authDetails->setAuthId('internal');

            // set the authid if the hello has one
            if ($msg instanceof HelloMessage) {
                $details = $msg->getDetails();
                if (isset($details) && isset($details->authid)) {
                    $authDetails->setAuthId($details->authid);
                }
            }

            $authDetails->addAuthRole('authenticated_user');
            $authDetails->addAuthRole('admin');

            $session->setAuthenticationDetails($authDetails);
            $session->setAuthenticated(true);

            $details             = new \stdClass();
            $details->authid     = $authDetails->getAuthId();
            $details->authmethod = $authDetails->getAuthMethod();
            $details->authrole   = $authDetails->getAuthRole();
            $details->authroles  = $authDetails->getAuthRoles();

            $session->sendMessage(new WelcomeMessage($session->getSessionId(), $details));

            return;
        }

        if (!$this->readyToAuthenticate()) {
            $session->abort(new \stdClass(), 'thruway.authenticator.not_ready');

            return;
        }

        if ($msg instanceof HelloMessage) {
            if ($session->getAuthenticationDetails() !== null) {
                // Todo: probably shouldn't be so dramatic here
                throw new \Exception(
                    'Hello message sent to authentication manager when there is already authentication details attached.'
                );
            }

            $this->handleHelloMessage($realm, $session, $msg);
        } else {
            if ($msg instanceof AuthenticateMessage) {
                $this->handleAuthenticateMessage($realm, $session, $msg);
            } else {
                throw new \Exception('Invalid message type sent to AuthenticationManager.');
            }
        }
    }
1016871
public function serverStopProcess($msg = null)
  {
    TeamSpeak3_Helper_Signal::getInstance()->emit("notifyServershutdown", $this);

    $this->execute("serverprocessstop", array("reasonmsg" => $msg));
  }
646360
public function onSessionStart($session, $transport)
    {
        $this->thePromise->then(function () use ($session) {
            $session->call('com.example.thefunction0', [])
                ->then(function ($res) {
                    echo "Done.\n";
                    exit;
                });
        });
    }
404238
public function leave(Session $session)
    {
        // remove all registrations that belong to this session
        /* @var $registration \Thruway\Registration */
        foreach ($this->registrations as $i => $registration) {
            if ($registration->getSession() === $session) {
                // if this session is the callee on pending calls - error them out
                $registration->errorAllPendingCalls();
                array_splice($this->registrations, $i, 1);
            }
        }
    }