Exemplo n.º 1
0
        public static void RegisterCallback(LuaFunction fnLoginCallback,
                                            LuaFunction fnLogoutCallback,
                                            LuaFunction fnBuyCallback)
        {
            LT_LOGIN_NOTIFICATION_DELEGATE  fnLogin  = null;
            LT_LOGOUT_NOTIFICATION_DELEGATE fnLogout = null;
            LT_BUY_NOTIFICATION_DELEGATE    fnBuy    = null;

            if (fnLoginCallback != null)
            {
                fnLogin = (iState, pUser) => {
                    int    eLoginState    = (int)iState;
                    string strUserName    = pUser.strUserName;
                    string strAccessToken = pUser.strAccessToken;
                    string strUserID      = pUser.strUserID;
                    bool   bGuest         = pUser.bGuest;

                    fnLoginCallback.Call(eLoginState,
                                         strUserName,
                                         strAccessToken,
                                         strUserID,
                                         bGuest);
                };
            }

            if (fnLogoutCallback != null)
            {
                fnLogout = (iState) =>
                {
                    bool bSuccess = (iState == SDK.LOGOUT_STATE.LT_LOGOUT_SUCCEED);

                    fnLogoutCallback.Call(bSuccess);
                };
            }

            if (fnBuyCallback != null)
            {
                fnBuy = (iState, pProduct) =>
                {
                    bool   bSuccess         = (iState == SDK.BUY_STATE.LT_BUY_SUCCEED);
                    int    iBillingType     = pProduct.iBillingType;
                    string strOrderId       = pProduct.strOrderId;
                    string strTransactionId = pProduct.strTransactionId;
                    string strReceipt       = pProduct.strReceipt;

                    fnBuyCallback.Call(bSuccess,
                                       iBillingType,
                                       strOrderId,
                                       strTransactionId,
                                       strReceipt);
                };
            }

            LT_Instance.RegisterCallback(fnLogin, fnLogout, fnBuy);
        }