/**
* Process call
*
* @param \Thruway\Session $session
* @param \Thruway\Message\CallMessage $msg
* @return boolean
*/
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);
}
}