Example #1
0
    public void ChangeUserAndPwd(String user, String pwd, Action <LoginResult> completeCall)
    {
        WXProtocol.Log("修改用户名和密码");

        curAction = OPERATEION.EDIT_USER_PWD;

        CheckUser(user, null, (b, d) =>
        {
            if (b)
            {
                List <object> list = d["data"] as List <object>;
                if (list.Count > 0)
                {
                    var dict = list[0] as Dictionary <string, object>;
                    if (dict["uid"].ToString() == WXProtocol.uid)
                    {
                        b = false;
                    }
                }
            }


            if (!b)
            {
                this.doneCallback = completeCall;
                string sql        = "http://api.waixing.com:8090/client/getMb.action?sql=update games_users set  name='" + user + "', pwd='" + pwd + "',  newtime = GETDATE()  where uid='" + WXProtocol.uid + "'&id=31";
                WXProtocol.instance.GetJson(sql, (json) =>
                {
                    WXProtocol.userName = user;
                    WXProtocol.userPwd  = pwd;
                    if (doneCallback != null)
                    {
                        doneCallback(new LoginResult()
                        {
                            success = true
                        });
                    }
                }, (faileStr) =>
                {
                    if (doneCallback != null)
                    {
                        doneCallback(new LoginResult()
                        {
                            reason = "您当前没有网络无法连接服务器"
                        });
                    }
                });
            }
            else
            {
                if (doneCallback != null)
                {
                    doneCallback(new LoginResult()
                    {
                        reason = "用户名已存在,请更换用户名重试"
                    });
                }
            }
        });
    }
Example #2
0
 /// <summary>
 /// 登你妹的陆啊
 /// </summary>
 /// <param name="doneCall"></param>
 public void Login(Action <LoginResult> doneCall, bool checkUserBefore = true)
 {
     curAction    = OPERATEION.LOGIN;
     doneCallback = doneCall;
     //用本机的UID注册一个
     WXProtocol.instance.GetJson("http://api.waixing.com:8090/client/getMb.action?sql=select * from games_users where uid = '" + WXProtocol.uid + "' &id=30", (json) =>
     {
         if (WXProtocol.CheckSuccess(json))
         {
             SetLoginID(json);
             WXProtocol.Log("UID" + WXProtocol.uid + "已注册,刷新上线时间为现在");
             RefreshLogin();
         }
         else
         {
             WXProtocol.Log("UID" + WXProtocol.uid + "未注册,新注册用户");
             CreateUser(); //需要拿上次登陆的UID来登陆,除非用户切换了账号
         }
     }, (failedReason) =>
     {
         LoginResult data = new LoginResult()
         {
             success = false, reason = failedReason
         };
         doneCall(data);
     });
 }
Example #3
0
    private void CheckUser(string user, string pwd, Action <bool, Dictionary <string, object> > callback)
    {
        string sql = "http://api.waixing.com:8090/client/getMb.action?sql=select * from games_users where name = '" + user + "'";

        if (pwd != null)
        {
            sql += " and pwd = '" + pwd + "' ";
        }
        sql += "&id=49";

        WXProtocol.instance.GetJson(sql, (json) =>
        {
            if (WXProtocol.CheckSuccess(json))
            {
                callback(true, json);
            }
            else
            {
                //没有这个用户的数据
                callback(false, null);
            }
        }, (failedReason) =>
        {
            callback(false, null);
        });
    }
Example #4
0
    private void GetGameData()
    {
        WXProtocol.Log("得到游戏表数据");


        string sql = "http://api.waixing.com:8090/client/getMb.action?sql=select * from " + WXProtocol.tableName
                     + " where id = " + WXProtocol.LoginID + "&id= " + WXProtocol.selectID;

        WXProtocol.instance.GetJson(sql, (json1) =>
        {
            if (WXProtocol.CheckSuccess(json1))
            {
                //有数据
                doneCallback(new LoginResult()
                {
                    success = true, data = json1
                });
            }
            else
            {
                //没有数据
                //新建一条数据
                WXProtocol.Log(json1["data"].ToString());
                WXProtocol.Log("新建游戏数据");
                WXProtocol.instance.GetJson("http://api.waixing.com:8090/client/doMb.action?sql=insert into " + WXProtocol.tableName
                                            + "(id,data) values(" + WXProtocol.LoginID + ", '{}')&id=" + WXProtocol.insertID, (json2) =>
                {
                    if (WXProtocol.CheckSuccess(json2))
                    {
                        doneCallback(new LoginResult()
                        {
                            success = true
                        });
                    }
                    else
                    {
                        doneCallback(new LoginResult()
                        {
                            success = false, reason = json2["data"].ToString()
                        });
                    }
                }, (s) => {
                    doneCallback(new LoginResult()
                    {
                        reason = s
                    });
                });
            }
        }, (failedReason) =>
        {
            doneCallback(new LoginResult()
            {
                reason = failedReason
            });
        });
    }
Example #5
0
    public void CreateUser(bool useMacUID = false)
    {
        string uid = useMacUID ? WXProtocol.macUID : WXProtocol.uid;

        WXProtocol.instance.GetJson("http://api.waixing.com:8090/client/doMb.action?sql=insert into games_users (uid,product,sdk,type,game,time) values('" + uid + "','" + WXProtocol.product + "','" + WXProtocol.sdk + "','" + WXProtocol.TYPE_ID + "', '" + WXProtocol.GAME_ID + "', GETDATE()) &id=32",
                                    (json) =>
        {
            if (WXProtocol.CheckSuccess(json))
            {
                WXProtocol.uid      = uid;
                WXProtocol.userPwd  = "";
                WXProtocol.userName = "";
                SaveUID(uid);
                WXProtocol.instance.GetJson("http://api.waixing.com:8090/client/getMb.action?sql=select * from games_users where uid = '" + WXProtocol.uid + "'&id=30", (d) =>
                {
                    if (WXProtocol.CheckSuccess(d))
                    {
                        SetLoginID(d);
                        GetGameData();
                    }
                    else
                    {
                        if (doneCallback != null)
                        {
                            doneCallback(new LoginResult()
                            {
                                reason = d["data"].ToString()
                            });
                        }
                    }
                }, (f) =>
                {
                    if (doneCallback != null)
                    {
                        doneCallback(new LoginResult()
                        {
                            reason = f
                        });
                    }
                });
            }
            else
            {
                if (doneCallback != null)
                {
                    doneCallback(new LoginResult()
                    {
                        reason = json["data"].ToString()
                    });
                }
            }
        }, LoginFailed);
    }
Example #6
0
    public void UpdateUserNameAndPWD(string newUID, string backUID, Action <bool> callback)
    {
        string sql = "http://api.waixing.com:8090/client/doMb.action?sql=update games_users set  uid='" + newUID + "', newtime = GETDATE()  where  uid = '" + backUID + "' &id=31";

        WXProtocol.instance.GetJson(sql, (json) =>
        {
            callback(WXProtocol.CheckSuccess(json));
        }, (failed) =>
        {
            callback(false);
        });
    }
Example #7
0
    /// <summary>
    /// 切换到空用户
    /// </summary>
    /// <param name="macUid"></param>
    /// <param name="doneCall"></param>
    public void SwitchUser(string macUid, Action <LoginResult> doneCall)
    {
        this.doneCallback = doneCall;
        CheckUid(macUid, (b, jsonData) =>
        {
            if (b) //理论上不应该存在
            {
                //用户存在的话,更新用户名密码为空吧?
                var list       = jsonData["data"] as List <object>;
                var dic        = list[0] as Dictionary <string, object>;
                String backUID = dic["uid"].ToString();

                string sql = "http://api.waixing.com:8090/client/doMb.action?sql=update games_users set  newtime = GETDATE()  where  uid = '" + backUID + "' &id=31";
                WXProtocol.instance.GetJson(sql, (json) =>
                {
                    if (WXProtocol.CheckSuccess(json))
                    {
                        SetLoginID(jsonData);
                        WXProtocol.uid = macUid;
                        SaveUID(WXProtocol.uid);
                        GetGameData();
                    }
                    else
                    {
                        if (doneCall != null)
                        {
                            doneCall(new LoginResult()
                            {
                                reason = json["data"].ToString()
                            });
                        }
                    }
                }, (failed) =>
                {
                    if (doneCall != null)
                    {
                        doneCall(new LoginResult()
                        {
                            reason = failed
                        });
                    }
                });
            }
            else
            {
                CreateUser(true);
            }
        });
    }
Example #8
0
    public void ExchangeMoney(int money, Action <bool, string> callback)
    {
        string sql = "http://api.waixing.com:8090/client/getMb.action?sql=select * from games_users where uid ='" + WXProtocol.uid + "'&id=30";

        WXProtocol.instance.GetJson(sql, (json) =>
        {
            if (WXProtocol.CheckSuccess(json))
            {
                List <object> data = json["data"] as List <object>;
                Dictionary <string, object> per = data[0] as Dictionary <string, object>;

                if (per.ContainsKey("money"))
                {
                    int m = int.Parse(per["money"].ToString());
                    if (money > m)
                    {
                        callback(false, "您的外星币不足以支付这次兑换");
                        return;
                    }

                    m -= money;



                    sql = "http://api.waixing.com:8090/client/doMb.action?sql=update games_users set money=" + m + " where uid = '" + WXProtocol.uid + "'&id=31";
                    WXProtocol.instance.GetJson(sql, (json1) =>
                    {
                        WXProtocol.Money = m;
                        callback(true, "您成功兑换了" + money + "游戏币");
                    }, (failedReson1) => {
                        callback(false, "兑换失败:" + json);
                    });
                }
                else
                {
                    if (json.ContainsKey("data"))
                    {
                        callback(false, "兑换失败:" + json["data"]);
                    }
                    else
                    {
                        callback(false, "兑换失败");
                    }
                }
            }
        }, (failedReason) =>
        {
        });
    }
Example #9
0
    public void TestAddMoney(int m)
    {
        string sql = "http://api.waixing.com:8090/client/getMb.action?sql=update games_users set money = " + m + " where id = " + WXProtocol.LoginID + "&id=31";

        WXProtocol.instance.GetJson(sql, (json) =>
        {
            if (WXProtocol.CheckSuccess(json))
            {
                Debug.Log("加" + m + "成功");
            }
            else
            {
                Debug.Log("加" + m + "失败");
            }
        }, (f) => {
            Debug.Log("加" + m + "失败:" + f);
        });
    }
Example #10
0
 public void RefreshLogin()
 {
     WXProtocol.instance.GetJson("http://api.waixing.com:8090/client/doMb.action?sql=update games_users set  newtime = GETDATE() where uid = '" + WXProtocol.uid + "' &id=31",
                                 (json) =>
     {
         if (WXProtocol.CheckSuccess(json))
         {
             GetGameData();
         }
         else
         {
             if (doneCallback != null)
             {
                 doneCallback(new LoginResult()
                 {
                     reason = json["data"].ToString()
                 });
             }
         }
     }, LoginFailed);
 }