00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #import <UIKit/UIKit.h>
00029
00030
00031 #import <CommonCrypto/CommonDigest.h>
00032
00033
00034 #import "cocoslive.h"
00035
00036
00037 #define SCORE_SERVER_PROTOCOL_VERSION @"1.1"
00038
00039
00040 #ifdef USE_LOCAL_SERVER
00041 #define SCORE_SERVER_SEND_URL @"http://localhost:8080/api/post-score"
00042 #define SCORE_SERVER_UPDATE_URL @"http://localhost:8080/api/update-score"
00043 #else
00044 #define SCORE_SERVER_SEND_URL @"http://www.cocoslive.net/api/post-score"
00045 #define SCORE_SERVER_UPDATE_URL @"http://www.cocoslive.net/api/update-score"
00046 #endif
00047
00049 typedef enum {
00051 kPostStatusOK = 0,
00054 kPostStatusConnectionFailed = 1,
00057 kPostStatusPostFailed = 2,
00058 } tPostStatus;
00059
00060 enum {
00062 kServerPostInvalidRanking = 0,
00063 };
00064
00068 @interface CLScoreServerPost : NSObject {
00071 NSString *gameKey;
00072
00074 NSString *gameName;
00075
00077 id delegate;
00078
00080 NSUInteger ranking_;
00081
00083 BOOL scoreDidUpdate_;
00084
00086 NSMutableData *receivedData;
00087
00089 NSMutableArray *bodyValues;
00090
00092 tPostStatus postStatus_;
00093
00095 CC_MD5_CTX md5Ctx;
00096
00098 NSURLConnection *connection_;
00099 }
00100
00102 @property (nonatomic,readonly) tPostStatus postStatus;
00103
00105 @property (nonatomic, retain) NSURLConnection *connection;
00106
00110 @property (nonatomic,readonly) NSUInteger ranking;
00111
00115 @property (nonatomic,readonly) BOOL scoreDidUpdate;
00116
00118 +(id) serverWithGameName:(NSString*) name gameKey:(NSString*) key delegate:(id)delegate;
00119
00121 -(id) initWithGameName:(NSString*) name gameKey:(NSString*) key delegate:(id)delegate;
00122
00124 -(BOOL) sendScore: (NSDictionary*) dict;
00125
00131 -(BOOL) updateScore: (NSDictionary*) dict;
00132
00133 @end
00134
00136 @protocol CLPostDelegate <NSObject>
00138 -(void) scorePostOk:(id) sender;
00140 -(void) scorePostFail:(id) sender;
00141 @end