cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
/Users/rquesada/progs/cocos2d-iphone/cocoslive/CLScoreServerRequest.h
00001 /*
00002  * cocos2d for iPhone: http://www.cocos2d-iphone.org
00003  *
00004  * Copyright (c) 2008-2010 Ricardo Quesada
00005  * Copyright (c) 2011 Zynga Inc.
00006  * 
00007  * Permission is hereby granted, free of charge, to any person obtaining a copy
00008  * of this software and associated documentation files (the "Software"), to deal
00009  * in the Software without restriction, including without limitation the rights
00010  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the Software is
00012  * furnished to do so, subject to the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice shall be included in
00015  * all copies or substantial portions of the Software.
00016  * 
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00022  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00023  * THE SOFTWARE.
00024  *
00025  */
00026 
00027 
00028 
00029 #import <UIKit/UIKit.h>
00030 
00031 // cocoslive definitions
00032 #import "cocoslive.h"
00033 
00034 // Server URL
00035 #if USE_LOCAL_SERVER
00036 #define SCORE_SERVER_REQUEST_URL @"http://localhost:8080/api/get-scores"
00037 #define SCORE_SERVER_GETRANK_URL @"http://localhost:8080/api/get-rank-for-score"
00038 #else
00039 #define SCORE_SERVER_REQUEST_URL @"http://www.cocoslive.net/api/get-scores"
00040 #define SCORE_SERVER_GETRANK_URL @"http://www.cocoslive.net/api/get-rank-for-score"
00041 #endif
00042 
00044 typedef enum {
00045         kQueryIgnore = 0,
00046         kQueryDay = 1,
00047         kQueryWeek = 2,
00048         kQueryMonth = 3,
00049         kQueryAllTime = 4,
00050 } tQueryType;
00051 
00053 typedef enum {
00054         kQueryFlagIgnore = 0,
00055         kQueryFlagByCountry = 1 << 0,
00056         kQueryFlagByDevice = 1 << 1,
00057 } tQueryFlags;
00058 
00062 @interface CLScoreServerRequest : NSObject {
00063         
00065         NSString        *gameName;
00066         
00068         id                      delegate;
00069         
00070         // data received
00071         NSMutableData *receivedData;
00072         
00073         // To determine which delegate method will be called in connectionDidFinishLoading: of NSURLConnection Delegate
00074         BOOL reqRankOnly;
00075         
00077         NSURLConnection *connection_;
00078 }
00079 
00081 @property (nonatomic, retain) NSURLConnection *connection;
00082 
00083 
00085 +(id) serverWithGameName:(NSString*) name delegate:(id)delegate;
00086 
00088 -(id) initWithGameName:(NSString*) name delegate:(id)delegate;
00089 
00095 -(BOOL) requestScores: (tQueryType) type limit:(int)limit offset:(int)offset flags:(tQueryFlags)flags category:(NSString*)category;
00096 
00101 -(BOOL) requestScores: (tQueryType) type limit:(int)limit offset:(int)offset flags:(tQueryFlags)flags;
00102 
00104 -(NSArray*) parseScores;
00105 
00110 -(BOOL) requestRankForScore:(int)score andCategory:(NSString*)category;
00111 
00113 -(int) parseRank;
00114 
00115 @end
00116 
00118 @protocol CLRequestDelegate <NSObject>
00119 -(void) scoreRequestOk:(id) sender;
00120 -(void) scoreRequestRankOk:(id) sender;
00121 -(void) scoreRequestFail:(id) sender;
00122 @end
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone API Reference - Generated using Doxygen 1.7.4