/**
* Handle transport recived message
*
* @param \Thruway\Transport\TransportInterface $transport
* @param \Thruway\Message\Message $msg
* @return void
*/
public function onMessage(TransportInterface $transport, Message $msg)
{
/* @var $session \Thruway\Session */
$session = $this->sessions[$transport];
// see if the session is in a realm
if ($session->getRealm() === null) {
if ($msg instanceof AbortMessage) {
$session->shutdown();
return;
}
// hopefully this is a HelloMessage or we have no place for this message to go
if ($msg instanceof HelloMessage) {
try {
$realm = $this->realmManager->getRealm($msg->getRealm());
$realm->onMessage($session, $msg);
} catch (\Exception $e) {
// TODO: Test this
$errorUri = "wamp.error.unknown";
$description = $e->getMessage();
if ($e instanceof InvalidRealmNameException || $e instanceof RealmNotFoundException) {
$errorUri = "wamp.error.no_such_realm";
}
$session->abort(['description' => $description], $errorUri);
}
} else {
$session->abort(new \stdClass(), "wamp.error.unknown");
}
} else {
$realm = $session->getRealm();
$realm->onMessage($session, $msg);
}
}