Exemple #1
0
    public override void HandleLoginMsg(string ret)
    {
        //Debugger.Log(ret);
        JsonData     jsonData = JsonMapper.ToObject(ret);
        LoginRetInfo retInfo  = new LoginRetInfo();

        if ((IDictionary)jsonData == null)
        {
            Debugger.Log("登录返回格式不正确");
            retInfo.Result = "返回非json数据";
        }
        else
        {
            retInfo.Result = ContainsKey(jsonData, "result") ? (string)jsonData["result"] : "没有result字段";
        }

        retInfo.Uid      = ContainsKey(jsonData, "user_id") ? (string)jsonData["user_id"] : "";
        retInfo.Token    = ContainsKey(jsonData, "token") ? (string)jsonData["token"] : "";
        retInfo.PlatType = ContainsKey(jsonData, "plat_type") ? (string)jsonData["plat_type"] : "";
        retInfo.Passwd   = ContainsKey(jsonData, "passwd") ? (string)jsonData["passwd"] : "";

        if (loginCallback != null)
        {
            loginCallback(retInfo);
        }
        else if (loginCallbackByLua != null)
        {
            Utility_LuaHelper.CallParaLuaFunc(loginCallbackByLua, retInfo.Uid, retInfo.Token, retInfo.PlatType, retInfo.Passwd, true);
        }
    }
Exemple #2
0
    public static void SwitchAccountByLua(string funcName)
    {
        //处理我们自己的切换帐号操作
        LuaFunction lf = LuaClient.GetMainState().GetFunction(funcName);

        if (lf != null)
        {
            LoginRetInfo retInfo = new LoginRetInfo();
            Utility_LuaHelper.CallParaLuaFunc(lf, retInfo.Uid, retInfo.Token, retInfo.PlatType, retInfo.Passwd, true);
        }
    }
Exemple #3
0
    virtual public void HandleLogoutMsg(string ret)
    {
        bool r;

        if (!bool.TryParse(ret, out r))
        {
            r = false;
        }
        if (logoutCallback != null)
        {
            logoutCallback(r);
        }
        else if (logoutCallbackByLua != null)
        {
            Utility_LuaHelper.CallParaLuaFunc(logoutCallbackByLua, r);
        }
    }