Example #1
0
 /**
  * Performs a GeoIP lookup
  * @param	callback	Action<PlayerCountry, PResponse>	Your callback method
  */
 public static void Lookup(Action <PlayerCountry, PResponse> callback)
 {
     PRequest.GetResponse(SECTION, LOOKUP, null, response => {
         var data = response.success ? response.json : null;
         callback(new PlayerCountry(data), response);
     });
 }
Example #2
0
 /**
  * Loads all GameVars
  * @param	callback	Action<Hashtable, PResponse>	Your callback method
  */
 public static void Load(Action <Hashtable, PResponse> callback)
 {
     PRequest.GetResponse(SECTION, LOAD, null, response => {
         var data = response.success ? response.json : null;
         callback(data, response);
     });
 }
 private static void SendSaveLoadRequest(string section, string action, Hashtable postdata, Action <PlayerLevel, PResponse> callback)
 {
     PRequest.GetResponse(section, action, postdata, response => {
         var level = response.success
                                         ? new PlayerLevel((Hashtable)response.json["level"])
                                         : null;
         callback(level, response);
     });
 }
 private static void SendListRequest(string section, string action, Hashtable postdata, Action <List <PlayerLevel>, int, PResponse> callback)
 {
     PRequest.GetResponse(section, action, postdata, response => {
         var data = response.json;
         List <PlayerLevel> levels;
         int numlevels;
         ProcessLevels(response, data, out levels, out numlevels);
         callback(levels, numlevels, response);
     });
 }
Example #5
0
 private static void SendListRequest(string section, string action, Hashtable postdata, Action <List <PlayerScore>, int, PResponse> callback)
 {
     PRequest.GetResponse(section, action, postdata, response => {
         var data = response.json;
         List <PlayerScore> scores;
         int numscores;
         ProcessScores(response, data, out scores, out numscores);
         callback(scores, numscores, response);
     });
 }
Example #6
0
        /**
         * Loads a single GameVar
         * @param	name	string	The variable name to load
         * @param	callback	Action<Hashtable, PResponse>	Your callback method
         */
        public static void LoadSingle(string name, Action <Hashtable, PResponse> callback)
        {
            var postdata = new Hashtable
            {
                { "name", name }
            };

            PRequest.GetResponse(SECTION, LOADSINGLE, postdata, response => {
                var data = response.success ? response.json : null;
                callback(data, response);
            });
        }
Example #7
0
        /**
         * Lists all achievements
         * @param	options		The list options
         * @param	callback	Your callback Action<List<Achievement>, PResponse>
         */
        public static void List(Hashtable options, Action <List <PlayerAchievement>, PResponse> callback)
        {
            PRequest.GetResponse(SECTION, LIST, options, response => {
                var data         = response.success ? response.json : null;
                var achievements = new List <PlayerAchievement>();
                if (response.success)
                {
                    var acharray = (ArrayList)data["achievements"];
                    achievements.AddRange(from object t in acharray select new PlayerAchievement((Hashtable)t));
                }

                callback(achievements, response);
            });
        }
        /**
         * Rates a level
         * @param	levelid	String	The level id
         * @param	rating	Int		Rating from 1 - 10
         * @param	callback	Action<PResponse> Your callback function
         */
        public static void Rate(string levelid, int rating, Action <PResponse> callback)
        {
            if (rating < 1 || rating > 10)
            {
                callback(PResponse.Error(401));
                return;
            }

            var postdata = new Hashtable
            {
                { "levelid", levelid },
                { "rating", rating }
            };

            PRequest.GetResponse(SECTION, RATE, postdata, callback);
        }
Example #9
0
        /**
         * Shows a chronological stream of achievements
         * @param	options		The stream options
         * @param	callback	Your callback Action<List<Achievement>, int, PResponse>
         */
        public static void Stream(Hashtable options, Action <List <PlayerAward>, int, PResponse> callback)
        {
            PRequest.GetResponse(SECTION, STREAM, options, response => {
                var data            = response.success ? response.json : null;
                int numachievements = response.success ? (int)(double)data["numachievements"] : 0;
                var achievements    = new List <PlayerAward>();

                if (response.success)
                {
                    var acharray = (ArrayList)data["achievements"];
                    achievements.AddRange(from object t in acharray select new PlayerAward((Hashtable)t));
                }

                callback(achievements, numachievements, response);
            });
        }
Example #10
0
 /**
  * Saves a player's score
  * @param	score	PlayerScore	The PlayerScore object
  * @param	callback	Action<PResponse> Your callback method
  */
 public static void Save(PlayerScore score, Action <PResponse> callback)
 {
     PRequest.GetResponse(SECTION, SAVE, score, callback);
 }
Example #11
0
 /**
  * Subscribes a person to your newsletter
  * @param	options	Hashtable	The email and other information
  * @param	callback	Action<PResponse>	Your callback function
  */
 public static void Subscribe(Hashtable options, Action <PResponse> callback)
 {
     PRequest.GetResponse(SECTION, SUBSCRIBE, options, response => {
         callback(response);
     });
 }
Example #12
0
 /**
  * Award an achievement to a player
  * @param	achievement	The achievement
  * @param	callback	Your callback Action<PResponse>
  */
 public static void Save(Hashtable achievement, Action <PResponse> callback)
 {
     PRequest.GetResponse(SECTION, SAVE, achievement, response => {
         callback(response);
     });
 }