Пример #1
0
void Session::open() {

    try {
        setSessionState(SigningIn);

        ScriptEngine *engine = ScriptEngine::instance();
        m_scriptObject = engine->evaluate("new SessionHandler()");
        if (engine->hasUncaughtException()) {
            LogUtil::logException("Script Exception: %1\n"
                                  "In Session::open()", engine->uncaughtException());
            return;
        }

        QScriptValue setSession = m_scriptObject.property("setSession");
        QScriptValueList args;
        args.append(engine->toScriptValue(this));
        setSession.call(m_scriptObject, args);

        if (engine->hasUncaughtException()) {
            LogUtil::logException("Script Exception: %1\n"
                                  "In Session::open()", engine->uncaughtException());
        }
    } catch (GameException &exception) {
        LogUtil::logError("Exception in Session::open(): %1", exception.what());
    }
}
Пример #2
0
void Session::processSignIn(const QString &data) {

    try {
        switch (m_sessionState) {
            case SessionClosed:
                break;

            case SigningIn: {
                QScriptValue processSignIn = m_scriptObject.property("processSignIn");
                QScriptValueList args;
                args.append(data.trimmed());
                processSignIn.call(m_scriptObject, args);
                break;
            }

            case SignedIn: {
                CommandEvent event(m_player, data);
                event.process();
                break;
            }
        }

        ScriptEngine *engine = ScriptEngine::instance();
        if (engine->hasUncaughtException()) {
            LogUtil::logException("Script Exception: %1\n"
                                  "In Session::processSignIn()", engine->uncaughtException());
        }
    } catch (GameException &exception) {
        LogUtil::logError("Exception in Session::processSignIn(): %1", exception.what());
    }
}