Create Registration from RegisterMessage

@param \Thruway\Session $session
@param \Thruway\Message\RegisterMessage $msg
@return \Thruway\Registration
356414
public static function createRegistrationFromRegisterMessage(Session $session, RegisterMessage $msg)
    {
        $registration = new self($session, $msg->getProcedureName());
        $options      = $msg->getOptions();

        if (isset($options->disclose_caller) && $options->disclose_caller === true) {
            $registration->setDiscloseCaller(true);
        }

        if (isset($options->invoke)) {
            $registration->setInvokeType($options->invoke);
        } else {
            if (isset($options->thruway_multiregister) && $options->thruway_multiregister === true) {
                $registration->setInvokeType(self::THRUWAY_REGISTRATION);
            } else {
                $registration->setInvokeType(self::SINGLE_REGISTRATION);
            }
        }

        return $registration;
    }
326838
public function chat(string $question, string $session)
    {
        return Request::exec(self::CHAT, compact('question', 'session'));
    }
446125
public function setSuccess($msg, $code = 0)
    {
        $this->data['success'] = true;
        $this->data['code']    = $code;
        $this->data['message'] = $msg;
        
        return $this;
    }
28108
public static function fromMessage(Message $msg)
    {
        $queueStatus = array();
        while ($msg->peek() !== null) {
            $action = $msg->shift();
            $queueStatus[$action] = array(
                'action'    => $action,
                'queue'     => $msg->shift(),
                'busy'      => $msg->shift(),
                'available' => $msg->shift()
            );
        }

        return new self($queueStatus);
    }
516823
public static function parse(string $msg): Message
    {
        $obj = new self;
        $parts = explode("\r\n", $msg);
        $obj->body = MessageBody::parse(array_pop($parts));
        foreach ($parts as $line) {
            if ($line) {
                $pair = explode(': ', $line);
                $obj->headers[$pair[0]] = $pair[1];
            }
        }
        return $obj;
    }
201916
public function registerSession($name, Session $session)
    {
        $name = strtolower($name);

        $this->sessions[$name] = $session;
    }
472442
public function set_error_message($rule, $msg)
	{
		empty($rule) and $rule = 0;
		$this->error_messages[$rule] = strval($msg);

		return $this;
	}
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);

    }
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);
            }
        }
    }
1003307
public function info($msg)
    {
        if ($this->iniGetBool('display_errors') === true) {
            $this->write((string)$msg, 'INFO');
        }

        return $this;
    }
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);
        }
    }
1339325
public static function registerCustomMessage($code, $mesg)
  {
    if(array_key_exists((int) $code, self::$messages))
    {
      throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " is already registered");
    }

    if(!is_string($mesg))
    {
      throw new self("custom message for code 0x" . strtoupper(dechex($code)) . " must be a string");
    }

    self::$messages[(int) $code] = new TeamSpeak3_Helper_String($mesg);
  }
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;
        }
    }
444495
public function setMsgs( $messagesByKey, $domain = null, $lang = null ) {
		foreach ( $messagesByKey as $key => $message ) {
			$this->setMsg( $key, $message, $domain, $lang );
		}
	}
376412
public function converse($sessionId, $message = null, Context $context = null, $stepIteration = self::MAX_STEPS_ITERATION)
    {
        $context = (null !== $context) ? $context : new Context();

        if ($stepIteration <= 0) {
            $error = new MaxIterationException("Max iteration exceeded");
            $this->actionMapping->error($sessionId, $context, $error);

            return $context;
        }

        try {
            $step = $this->getNextStep($sessionId, $message, $context);
        } catch (\Exception $e) {
            // Trigger the error action
            $stepData = $e instanceof ConversationException ? $e->getStepData() : [];
            $this->actionMapping->error($sessionId, $context, $e, $stepData);

            return new Context();
        }

        return $this->performStep($sessionId, $step, $context, $stepIteration);
    }
1066969
public function between($min, $max, $msg)
    {
        $this->min($min, $msg);
        $this->max($max, $msg);
        return $this;
    }
755406
private function _setSession(Session $session)
	{
		$selectors_handler = $session->getSelectorsHandler();

		if ( !$selectors_handler->isSelectorRegistered('se') ) {
			$selectors_handler->registerSelector('se', new SeleniumSelector());
		}

		$this->_session = $session;

		return $this;
	}