|
cocos2d for iPhone 1.0.0
2D engine for iOS and OS X
|
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 // for MD5 signing 00032 #import <CommonCrypto/CommonDigest.h> 00033 00034 // cocoslive definitions 00035 #import "cocoslive.h" 00036 00037 // Score Server protocol version 00038 #define SCORE_SERVER_PROTOCOL_VERSION @"1.1" 00039 00040 // Server URL 00041 #ifdef USE_LOCAL_SERVER 00042 #define SCORE_SERVER_SEND_URL @"http://localhost:8080/api/post-score" 00043 #define SCORE_SERVER_UPDATE_URL @"http://localhost:8080/api/update-score" 00044 #else 00045 #define SCORE_SERVER_SEND_URL @"http://www.cocoslive.net/api/post-score" 00046 #define SCORE_SERVER_UPDATE_URL @"http://www.cocoslive.net/api/update-score" 00047 #endif 00048 00050 typedef enum { 00052 kPostStatusOK = 0, 00055 kPostStatusConnectionFailed = 1, 00058 kPostStatusPostFailed = 2, 00059 } tPostStatus; 00060 00061 enum { 00063 kServerPostInvalidRanking = 0, 00064 }; 00065 00069 @interface CLScoreServerPost : NSObject { 00072 NSString *gameKey; 00073 00075 NSString *gameName; 00076 00078 id delegate; 00079 00081 NSUInteger ranking_; 00082 00084 BOOL scoreDidUpdate_; 00085 00087 NSMutableData *receivedData; 00088 00090 NSMutableArray *bodyValues; 00091 00093 tPostStatus postStatus_; 00094 00096 CC_MD5_CTX md5Ctx; 00097 00099 NSURLConnection *connection_; 00100 } 00101 00103 @property (nonatomic,readonly) tPostStatus postStatus; 00104 00106 @property (nonatomic, retain) NSURLConnection *connection; 00107 00111 @property (nonatomic,readonly) NSUInteger ranking; 00112 00116 @property (nonatomic,readonly) BOOL scoreDidUpdate; 00117 00119 +(id) serverWithGameName:(NSString*) name gameKey:(NSString*) key delegate:(id)delegate; 00120 00122 -(id) initWithGameName:(NSString*) name gameKey:(NSString*) key delegate:(id)delegate; 00123 00125 -(BOOL) sendScore: (NSDictionary*) dict; 00126 00132 -(BOOL) updateScore: (NSDictionary*) dict; 00133 00134 @end 00135 00137 @protocol CLPostDelegate <NSObject> 00139 -(void) scorePostOk:(id) sender; 00141 -(void) scorePostFail:(id) sender; 00142 @end