Example #1
0
        private IEnumerator RestorePlayerDataActions(string dataKey)
        {
            string URL = "/app/player/unlock";
            IDictionary <string, object> reqBody = WebData.QuickDict("uid", Uid, "key", dataKey);
            WWW req = SignedWWW(URL, SigningKey, reqBody);

            yield return(req);
        }
Example #2
0
        private WWW LoginWWW()
        {
            IDictionary <string, object> loginBody = WebData.QuickDict(
                "uid", Uid,
                "now", UnixUtcNow());

            return(SignedWWW("/app/multi/login", Encoding.UTF8.GetBytes(SecretKey), loginBody));
        }
Example #3
0
        /// <summary>
        /// get list of previous players based on device id
        /// </summary>
        /// <returns></returns>

        private IEnumerator SearchPreviousPlayersActions()
        {
            string URL = "/app/player/device";
            IDictionary <string, object> reqbody = WebData.QuickDict("dev", GetUniqueDeviceID());

            Debug.Log(GetUniqueDeviceID());
            byte[] appKey = Encoding.UTF8.GetBytes(ApplicationKey);
            yield return(SignedWWW(URL, appKey, reqbody));
        }
Example #4
0
        private IEnumerator RegisterPlayerActions(string nick, string locale, bool reclaim = false)
        {
            // This is the player's initial nickname
            Nick = nick;

            // generate secret key for new player
            RandomNumberGenerator gen = RandomNumberGenerator.Create();

            byte[] secretBytes = new byte[32];
            gen.GetBytes(secretBytes);
            SecretKey = WebData.BytesToHex(secretBytes);
            byte[] appKey = Encoding.UTF8.GetBytes(ApplicationKey);

            // yield a WWW object to get the new player's UUID
            IDictionary <string, object> reqBody = WebData.QuickDict(
                "nik", nick,
                "key", SecretKey,
                "dev", GetUniqueDeviceID(),
                "loc", locale
                );

            // if we want to re-register same name on same device as previously...
            if (reclaim)
            {
                reqBody["rec"] = true;
            }

            WWW req = SignedWWW("/app/multi/register", appKey, reqBody);

            yield return(req);

            if (String.IsNullOrEmpty(req.error))
            {
                IDictionary <string, object> resDict = WebData.DictFromBytes(req.bytes);
                if (resDict != null)
                {
                    Uid    = resDict["uid"] as string;
                    Banned = resDict.ContainsKey("ban") && (bool)(resDict["ban"]);
                }
                else
                {
                    Uid = null;
                    yield return(RequestStatus.FAIL_UNKNOWN);
                }
            }
            else
            {
                Debug.LogError("RegisterPlayer: " + req.error);
            }
        }
Example #5
0
        private IEnumerator ChangeNicknameActions(string newNick)
        {
            // send request to change nickname
            IDictionary <string, object> reqBody = WebData.QuickDict("uid", Uid, "nik", newNick);
            WWW req = SignedWWW("/app/multi/rename", SigningKey, reqBody);

            yield return(req);

            if (String.IsNullOrEmpty(req.error))
            {
                Nick   = newNick;
                Banned = false;
            }
        }
Example #6
0
        private IEnumerator RatePlayerActions(string to, string mesg, string board, int amount)
        {
            IDictionary <string, object> body = WebData.QuickDict("uid", Uid, "to", to, "msg", mesg, "inc", amount);

            yield return(SignedWWW("/app/message/rate/" + UrlEncode(board), SigningKey, body));
        }
Example #7
0
        private IEnumerator RecvMessagesActions(int limit = 100)
        {
            IDictionary <string, object> body = WebData.QuickDict("uid", Uid, "lim", limit);

            yield return(SignedWWW("/app/message/recv", SigningKey, body));
        }
Example #8
0
        private IEnumerator SendMessageActions(string to, string mesg)
        {
            IDictionary <string, object> body = WebData.QuickDict("uid", Uid, "to", to, "msg", mesg);

            yield return(SignedWWW("/app/message/send", SigningKey, body));
        }
Example #9
0
        private IEnumerator PostScoreActions(string board, int score)
        {
            IDictionary <string, object> body = WebData.QuickDict("score", score);

            yield return(SignedWWW(String.Format("/app/player/{0}/score/{1}", Uid, UrlEncode(board)), SigningKey, body));
        }
Example #10
0
        private IEnumerator UnlinkPlayerActions(string other)
        {
            IDictionary <string, object> linkBody = WebData.QuickDict("uid", Uid, "lnk", other);

            yield return(SignedWWW("/app/player/unlink", SigningKey, linkBody));
        }