示例#1
0
        private void HandlePlayerResponse(DReq req, PlayerResponse res)
        {
            if (req.IsError)
            {
                res.Invoke(new PlayerRes(req.ErrorCode));
                return;
            }
            if (req.ContainSubData)
            {
                List <DPlayer> foundPlayers = new List <DPlayer>();
                foreach (string player in req.GetMainDatas())
                {
                    foundPlayers.Add(new DPlayer(player.Split(DReq.SUB_DELIMITER)));
                }
                foundPlayers.ForEach(p => WriteDebug("Palyer " + p.Name + " is loaded"));
                res.Invoke(new PlayerRes(foundPlayers));
                return;
            }

            WriteDebug("Palyer " + req.GetMainDatas()[2] + " is loaded");
            res.Invoke(new PlayerRes(new DPlayer(req.GetMainDatas())));
        }
示例#2
0
        public void Register(string username, string ingamename, string password, string email, int reflink, PlayerResponse playerResponse)
        {
            if (IsLoginKeySet())
            {
                playerResponse.Invoke(new PlayerRes(-1));
                return;
            }

            PlayerResponse r = new PlayerResponse(playerResponse);

            string[] keys = { "un", "ig", "ps", "email", "ref" };
            string[] vals = { username, ingamename, password, email, reflink.ToString() };

            SendAPIRequest(BuildURL("register", keys, vals), (res) =>
            {
                if (res.IsError)
                {
                    r.Invoke(new PlayerRes(res.ErrorCode));
                    return;
                }
                loginkey = res.Data;
                ReturnWithPlayerInfos(r);
            });
        }
示例#3
0
        public void Login(string username, string password, PlayerResponse playerResponse)
        {
            if (IsLoginKeySet())
            {
                playerResponse.Invoke(new PlayerRes(-1));
                return;
            }

            PlayerResponse r = new PlayerResponse(playerResponse);

            string[] keys = { "un", "ps" };
            string[] vals = { username, CreateMD5(password) };

            SendAPIRequest(BuildURL("login", keys, vals), (res) =>
            {
                if (res.IsError)
                {
                    r.Invoke(new PlayerRes(res.ErrorCode));
                    return;
                }
                loginkey = res.Data;
                ReturnWithPlayerInfos(r);
            });
        }