void onRestored(const sdkbox::Product& p) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("event", LuaValue::stringValue("onRestored")));
        dict.insert(std::make_pair("product", prouct2LuaValue(p)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    void onInitialized(bool ok) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("event", LuaValue::stringValue("onInitialized")));
        dict.insert(std::make_pair("ok", LuaValue::booleanValue(ok)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onReveal( const std::string& reveal_name) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onReveal")));
        dict.insert(std::make_pair("reveal_name", LuaValue::stringValue(reveal_name)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
 void onChartboostFailToRecordClick(const std::string& name, sdkbox::CB_ClickError e) {
     LuaStack* stack = LUAENGINE->getLuaStack();
     LuaValueDict dict;
     dict.insert(std::make_pair("func", LuaValue::stringValue("onChartboostFailToRecordClick")));
     dict.insert(std::make_pair("name", LuaValue::stringValue(name)));
     dict.insert(std::make_pair("e", LuaValue::intValue(e)));
     stack->pushLuaValueDict(dict);
     stack->executeFunctionByHandler(mLuaHandler, 1);
 }
    virtual void onConnectionStatusChanged( int status ) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onConnectionStatusChanged")));
        dict.insert(std::make_pair("status", LuaValue::intValue((int)status)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    void onProductRequestFailure(const std::string& msg) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("event", LuaValue::stringValue("onProductRequestFailure")));
        dict.insert(std::make_pair("msg", LuaValue::stringValue(msg)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
 void onChartboostReward(const std::string& name, int reward) {
     LuaStack* stack = LUAENGINE->getLuaStack();
     LuaValueDict dict;
     dict.insert(std::make_pair("func", LuaValue::stringValue("onChartboostReward")));
     dict.insert(std::make_pair("name", LuaValue::stringValue(name)));
     dict.insert(std::make_pair("reward", LuaValue::intValue(reward)));
     stack->pushLuaValueDict(dict);
     stack->executeFunctionByHandler(mLuaHandler, 1);
 }
    void onProductRequestSuccess(const std::vector<sdkbox::Product>& products) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("event", LuaValue::stringValue("onProductRequestSuccess")));
        dict.insert(std::make_pair("products", proucts2LuaValue(products)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);

    }
    LuaValue prouct2LuaValue(const sdkbox::Product& p) {
        LuaValueDict dicLua;
        dicLua.insert(std::make_pair("name", LuaValue::stringValue(p.name)));
        dicLua.insert(std::make_pair("id", LuaValue::stringValue(p.id)));
        dicLua.insert(std::make_pair("title", LuaValue::stringValue(p.title)));
        dicLua.insert(std::make_pair("description", LuaValue::stringValue(p.description)));
        dicLua.insert(std::make_pair("price", LuaValue::stringValue(p.price)));

        return LuaValue::dictValue(dicLua);
    }
    void onSharedCancel()
    {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onSharedCancel")));
        dict.insert(std::make_pair("data", LuaValue::stringValue("{}")));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    void onSharedFailed(const std::string& message)
    {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onSharedFailed")));
        dict.insert(std::make_pair("data", LuaValue::stringValue(message)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
 void onGetUserInfo( const sdkbox::FBGraphUser& user ) {
     LuaStack* stack = LUAENGINE->getLuaStack();
     
     LuaValueDict dict;
     dict.insert(std::make_pair("name", LuaValue::stringValue("onGetUserInfo")));
     dict.insert(std::make_pair("data", FBGraphUserToLua(user)));
     
     stack->pushLuaValueDict(dict);
     stack->executeFunctionByHandler(mLuaHandler, 1);
 }
 void invokeLuaHandler(const char* func, const char* name) {
     LuaStack* stack = LUAENGINE->getLuaStack();
     LuaValueDict dict;
     dict.insert(std::make_pair("func", LuaValue::stringValue(func)));
     if (nullptr != name) {
         dict.insert(std::make_pair("name", LuaValue::stringValue(name)));
     }
     stack->pushLuaValueDict(dict);
     stack->executeFunctionByHandler(mLuaHandler, 1);
 }
    void onPlayEnds(bool played_ok)
    {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onPlayEnds")));
        dict.insert(std::make_pair("played_ok", LuaValue::booleanValue(played_ok)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onSaveGameData(bool success, const std::string& error) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onSaveGameData")));
        dict.insert(std::make_pair("success", LuaValue::booleanValue(success)));
        dict.insert(std::make_pair("error", LuaValue::stringValue(error)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    void onCloseInterstitial(const char *placement) {
        LuaStack* stack = LUAENGINE->getLuaStack();
        LuaValueDict dict;

        dict.insert(std::make_pair("event", LuaValue::stringValue("onCloseInterstitial")));
        dict.insert(std::make_pair("placement", LuaValue::stringValue(placement)));

        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onAchievementsLoaded( bool reload_forced, const std::string& json_achievements_info ) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onAchievementsLoaded")));
        dict.insert(std::make_pair("reload_forced", LuaValue::booleanValue(reload_forced)));
        dict.insert(std::make_pair("json_achievements_info", LuaValue::stringValue(json_achievements_info)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onSetSteps( const std::string& step_name, double steps ) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onSetSteps")));
        dict.insert(std::make_pair("step_name", LuaValue::stringValue(step_name)));
        dict.insert(std::make_pair("steps", LuaValue::floatValue(steps)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onIncrementalAchievementUnlocked( const std::string& achievement_name ) {

        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onIncrementalAchievementUnlocked")));
        dict.insert(std::make_pair("achievement_name", LuaValue::stringValue(achievement_name)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    void onRequestOpenURL(const char *placement, const char *URL) {
        LuaStack* stack = LUAENGINE->getLuaStack();
        LuaValueDict dict;

        dict.insert(std::make_pair("event", LuaValue::stringValue("onRequestOpenURL")));
        dict.insert(std::make_pair("placement", LuaValue::stringValue(placement)));
        dict.insert(std::make_pair("URL", LuaValue::stringValue(URL)));

        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    void onAPI(const std::string& tag, const std::string& jsonData)
    {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onAPI")));
        dict.insert(std::make_pair("tag", LuaValue::stringValue(tag)));
        dict.insert(std::make_pair("data", LuaValue::stringValue(jsonData)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onRevealError( const std::string& reveal_name, int error_code, const std::string& error_description ) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onRevealError")));
        dict.insert(std::make_pair("reveal_name", LuaValue::stringValue(reveal_name)));
        dict.insert(std::make_pair("error_code", LuaValue::intValue(error_code)));
        dict.insert(std::make_pair("error_description", LuaValue::stringValue(error_description)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
 void onInviteFriendsWithInviteIdsResult(bool ok, const std::string& msg)
 {
     LuaStack* stack = LUAENGINE->getLuaStack();
     
     LuaValueDict dict;
     dict.insert(std::make_pair("name", LuaValue::stringValue("onInviteFriendsWithInviteIdsResult")));
     dict.insert(std::make_pair("ok", LuaValue::booleanValue(ok)));
     dict.insert(std::make_pair("data", LuaValue::stringValue(msg)));
     stack->pushLuaValueDict(dict);
     stack->executeFunctionByHandler(mLuaHandler, 1);
 }
    virtual void onAchievementUnlockError( const std::string& achievement_name, int error_code, const std::string& error_description ) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue(__FUNCTION__)));
        dict.insert(std::make_pair("achievement_name", LuaValue::stringValue(achievement_name)));
        dict.insert(std::make_pair("error_code", LuaValue::intValue(error_code)));
        dict.insert(std::make_pair("error_description", LuaValue::stringValue(error_description)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onAdAction( const std::string& ad_unit_id, const std::string& zone_place_location, sdkbox::AdActionType action_type) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onAdAction")));
        dict.insert(std::make_pair("ad_unit_id", LuaValue::stringValue(ad_unit_id)));
        dict.insert(std::make_pair("ad_name", LuaValue::stringValue(zone_place_location)));
        dict.insert(std::make_pair("ad_action_type", LuaValue::intValue((int)action_type)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    void onLogin(bool isLogin, const std::string& error)
    {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onLogin")));
        dict.insert(std::make_pair("isLoggedIn", LuaValue::booleanValue(isLogin)));
        dict.insert(std::make_pair("data", LuaValue::stringValue(error)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    void onRestoreComplete(bool ok, const std::string& msg)
    {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("event", LuaValue::stringValue("onRestoreComplete")));
        dict.insert(std::make_pair("ok", LuaValue::booleanValue(ok)));
        dict.insert(std::make_pair("msg", LuaValue::stringValue(msg)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onMyScore( const std::string& leaderboard_name, int time_span, int collection_type, long score ) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onMyScore")));
        dict.insert(std::make_pair("leaderboard_name", LuaValue::stringValue(leaderboard_name)));
        dict.insert(std::make_pair("time_span", LuaValue::intValue(time_span)));
        dict.insert(std::make_pair("collection_type", LuaValue::intValue(collection_type)));
        dict.insert(std::make_pair("score", LuaValue::intValue(score)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }
    virtual void onGameData(const std::string& action, const std::string& name, const std::string& data, const std::string& error) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onGameData")));
        dict.insert(std::make_pair("action", LuaValue::stringValue(action)));
        dict.insert(std::make_pair("save_name", LuaValue::stringValue(name)));
        dict.insert(std::make_pair("data", LuaValue::stringValue(data)));
        dict.insert(std::make_pair("error", LuaValue::stringValue(error)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    };
    virtual void onSetStepsError( const std::string& step_name, double steps, int error_code, const std::string& error_description ) {
        LuaStack* stack = LUAENGINE->getLuaStack();

        LuaValueDict dict;
        dict.insert(std::make_pair("name", LuaValue::stringValue("onSetStepsError")));
        dict.insert(std::make_pair("step_name", LuaValue::stringValue(step_name)));
        dict.insert(std::make_pair("steps", LuaValue::floatValue(steps)));
        dict.insert(std::make_pair("error_code", LuaValue::intValue(error_code)));
        dict.insert(std::make_pair("error_description", LuaValue::stringValue(error_description)));
        stack->pushLuaValueDict(dict);
        stack->executeFunctionByHandler(mLuaHandler, 1);
    }