示例#1
0
    public static void SetBindFlagIsTrue()
    {
        Cookie cookie = CookieData.GetInstance().Load();

        cookie.IsBind = true;
        CookieData.GetInstance().Save(cookie);
    }
示例#2
0
 public void Init()
 {
     if (Application.platform == RuntimePlatform.IPhonePlayer)
     {
         sdkCode = SDKCode.DEVICE_IOS;
         //1、keychain中查找imei.2、找到返回imei.3、没找到生成imei,存入keychain,返回imei
         openid = _GetUUID();
     }
     else if (Application.platform == RuntimePlatform.Android)
     {
         sdkCode = SDKCode.DEVICE_ANDROID;
         openid  = SystemInfo.deviceUniqueIdentifier;
     }
     else if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)
     {
         sdkCode = SDKCode.DEVICE_PC;
         openid  = (appCfg.TestPlayerIMEI == null || "".Equals(appCfg.TestPlayerIMEI))? SystemInfo.deviceUniqueIdentifier: appCfg.TestPlayerIMEI;
         Cookie cookie = CookieData.GetInstance().Load();
         if (cookie != null)
         {
             if (cookie.SdkCode == SDKCode.DEVICE_PC)
             {
                 string IMEINew = appCfg.TestPlayerIMEI == null ? "" : appCfg.TestPlayerIMEI;
                 string IMEIOld = PlayerPrefs.GetString(CodeMap.Filed.Filed_IMEI.ToString(), "") == null ? "" : PlayerPrefs.GetString(CodeMap.Filed.Filed_IMEI.ToString(), "");
                 if (!IMEINew.Equals(IMEIOld))
                 {
                     CookieData.GetInstance().Clear();
                     PlayerPrefs.SetString(CodeMap.Filed.Filed_IMEI.ToString(), IMEINew);
                     PlayerPrefs.Save();
                 }
             }
         }
     }
 }
示例#3
0
    public override void DoInWraper(Msg msg)
    {
        int rsCode = (int)msg.GetParam(AccountSrvCodeMap.Param.RS_CODE);

        if (rsCode == AccountSrvCodeMap.RsCode.ERRO_ACCOUNT_OP_BIND_SUCCESS || rsCode == AccountSrvCodeMap.RsCode.SUCCESS)
        {
            Cookie cookie = CookieData.GetInstance().Load();
            cookie.IsBind = true;
            CookieData.GetInstance().Save(cookie);
        }
        CmdCallback(msg);
    }
示例#4
0
    public void OnSdkLoginReturn(int sdkCode, string openid, string ext1)
    {
        this.sdkCode = sdkCode;
        this.openid  = openid;
        this.ext1    = ext1;
        Cookie cookie = CookieData.GetInstance().Load();

        if (cookie != null)
        {
            if (cookie.SdkCode != sdkCode || cookie.Openid != openid)
            {
                CookieData.GetInstance().Clear();
            }
        }
    }
示例#5
0
    public static bool IsBind()
    {
        Cookie cookie = CookieData.GetInstance().Load();

        if (cookie == null)
        {
            return(false);
        }
        int sdkCode = cookie.SdkCode;

        if (sdkCode != SDKCode.DEVICE_ANDROID && sdkCode != SDKCode.DEVICE_IOS && sdkCode != SDKCode.DEVICE_PC)
        {
            return(true);
        }
        return(cookie.IsBind);
    }
示例#6
0
    private void LoginWithCookie(Msg loginMsg)
    {
        Cookie cookie = CookieData.GetInstance().Load();

        if (cookie == null)
        {
            logReport.OnDebugReport("cookie is null");
            openid  = LoginIniter.getInst().Openid;
            sdkCode = LoginIniter.getInst().SdkCode;
            string pwd = LoginIniter.getInst().Ext1;
            if (openid == null || "".Equals(openid) || 0 == sdkCode)
            {
                logReport.OnWarningReport("openid and sdkid error!");
                return;
            }
            loginMsg.AddParam(AccountSrvCodeMap.Param.ACCOUNT_OPEN_ID, openid);              //设备号
            loginMsg.AddParam(AccountSrvCodeMap.Param.ACCOUNT_SDK_CODE, sdkCode);
            if (!"".Equals(pwd))
            {
                loginMsg.AddParam(AccountSrvCodeMap.Param.ACCOUNT_PWD, pwd);
            }
            loginMsg.AddParam(AccountSrvCodeMap.Param.ACCOUNT_SRV_VERSION, appCfg.PkgVersion);
            sendHttpMessage(appCfg.LoginUrl, loginMsg, OnhttpLoginReturn, AccountSrvTimeOut);
        }
        else
        {
            uid            = cookie.Uid;
            token          = cookie.Token;
            srvid          = cookie.Srvid;
            tokenTimestamp = cookie.TokenTimestamp;
            isBind         = cookie.IsBind;
            openid         = cookie.Openid;
            sdkCode        = cookie.SdkCode;
            string loginfo = "save cookie info(accountid:" + this.uid + ","
                             + "accountToken:" + token + ","
                             + "srvid:" + srvid + ","
                             + "tokenTimestamp:" + tokenTimestamp + ")";
            logReport.OnLogReport(loginfo);
            Msg msg = new Msg(AccountSrvCodeMap.Cmd.CMD_ACCOUNT_GET_SERVER_INFO);
            msg.AddParam(AccountSrvCodeMap.Param.ACCOUNT_SRV_VERSION, appCfg.Version);
            msg.AddParam(AccountSrvCodeMap.Param.ACCOUNT_SRV_ID, srvid);
            msg.AddParam(AccountSrvCodeMap.Param.ACCOUNT_SRV_VERSION, appCfg.PkgVersion);
            sendHttpMessage(appCfg.LoginUrl, msg, srvInfoReturn, AccountSrvTimeOut);
        }
    }
示例#7
0
    private void OnSocketLoginReturn(Msg msg)
    {
        int rsCode = (int)msg.GetParam(BaseCodeMap.BaseParam.RS_CODE);

        switch (rsCode)
        {
        case BaseCodeMap.BaseRsCode.SUCCESS:
            playerid       = (string)msg.GetParam(GameSrvCodeMap.Param.PLAYER_ID);
            testLoginTimes = DEFAULT_TEST_LOGIN_TIME;
            isLogined      = true;
            Cookie cookie = new Cookie(uid, token, srvid, tokenTimestamp, isBind, openid, sdkCode);
            CookieData.GetInstance().Save(cookie);
            GameSrvConnectSuccess();
            logReport.OnLogReport("loginSuccess->pid:" + playerid + ",uid:" + msg.GetParam(GameSrvCodeMap.Param.UID) + ",srvid:" + msg.GetParam(GameSrvCodeMap.Param.SRVID));
            break;

        case GameSrvCodeMap.RsCode.ERRO_CODE_FORCE_UPDATE_VERSION:
            logReport.OnWarningReport("versionNeedUpdate");
            onClosed();
            Close();
            break;

        case GameSrvCodeMap.RsCode.ERRO_CODE_TOKEN_EXPIRED:
            logReport.OnWarningReport("loginTokenExpiredAndRelogin.");
            testLoginTimes--;
            CookieData.GetInstance().Clear();
            if (testLoginTimes > 0)
            {
                Close();
                login(ConnectSocketComplete, this.accountSrvComplete);
            }
            else
            {
                onClosed();
            }
            break;

        case GameSrvCodeMap.RsCode.ERRO_CODE_INVALIDE_TOKEN:
            logReport.OnWarningReport("login token invalid,relogin.");
            CookieData.GetInstance().Clear();
            onClosed();
            Close();
            break;

        case GameSrvCodeMap.RsCode.ERR_CODE_SRV_ERRO:
            logReport.OnWarningReport("login fail.srv erro");
            onClosed();
            Close();
            break;

        case BaseCodeMap.BaseRsCode.TIME_OUT:
            logReport.OnWarningReport("login fail.time out");
            onClosed();
            Close();
            break;

        default:
            logReport.OnWarningReport("login fail,code:" + rsCode);
            CookieData.GetInstance().Clear();
            Close();
            break;
        }
        ;
        if (ConnectSocketComplete != null)
        {
            ConnectSocketComplete(Check(), msg);
            ConnectSocketComplete = null;
        }
    }
示例#8
0
 public void VistorLogin(ConnectInternetResultHandler SocketComplete, ConnectInternetResultHandler accountSrvComplete)
 {
     CookieData.GetInstance().Clear();
     LoginIniter.getInst().Init();
     login(SocketComplete, accountSrvComplete);
 }
示例#9
0
 public void accountAuthLogin(int sdkCode, String userName, String pwd, ConnectInternetResultHandler SocketComplete, ConnectInternetResultHandler accountSrvComplete)
 {
     CookieData.GetInstance().Clear();
     LoginIniter.getInst().OnSdkLoginReturn(sdkCode, userName, pwd);
     login(SocketComplete, accountSrvComplete);
 }
示例#10
0
 public void LogOutAndClearCookie()
 {
     CookieData.GetInstance().Clear();
     Close();
 }