00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #ifndef DPush_DPClient_h
00010 #define DPush_DPClient_h
00011 
00012 #import <Foundation/Foundation.h>
00013 #import <JavaScriptCore/JavaScriptCore.h>
00014 
00015 
00016 
00017 
00018 
00019 @interface GroupInfo : NSObject
00020 
00021 
00022 + (GroupInfo*) initWithId:(NSString*)groupid;
00023 
00024 + (GroupInfo*) initWithId:(NSString*)groupid custevent:(BOOL)iscustevent sendevent:(BOOL)issendevent;
00025 
00026 
00027 @property (nonatomic, copy) void (^onCallback)();
00028 
00029 
00030 
00031 
00032 
00033 @property (nonatomic, copy) void (^onUserIn)(NSString* cid, NSObject* custinfo);
00034 
00035 
00036 
00037 
00038 
00039 @property (nonatomic, copy) void (^onUserOut)(NSString* cid, NSObject* custinfo);
00040 
00041 
00042 
00043 
00044 
00045 @property (nonatomic, copy) void (^onUserUpdated)(NSString* cid, NSObject* custinfo);
00046 
00047 
00048 
00049 @property (nonatomic, copy) void (^onAuth)();
00050 
00051 
00052 
00053 
00054 
00055 
00056 - (void)onReceive:(NSString *)action callback:(void (^)(NSObject *args))function;
00057 
00058 
00059 
00060 
00061 
00062 
00063 - (void)send:(NSString *)action message:(NSString *)message;
00064 
00065 
00066 
00067 
00068 
00069 - (NSDictionary*)getUserList;
00070 
00071 
00072 
00073 
00074 
00075 
00076 - (NSObject*)getUserInfo:(NSString*)cid;
00077 
00078 
00079 
00080 
00081 
00082 - (void)updateUser:(NSDictionary *)custinfo;
00083 @end
00084 
00085 
00086 
00087 
00088 
00089 @interface GroupOptions : NSObject
00090 
00091 @property BOOL custevent;
00092 
00093 @property BOOL sendevent;
00094 
00095 @property NSDictionary* custinfo;
00096 
00097 @property NSString* authparam;
00098 
00099 
00100 
00101 
00102 @property (nonatomic, copy) void (^onAuth)();
00103 
00104 @end
00105 
00106 
00107 
00108 
00109 
00110 @interface DPOptions : NSObject
00111 
00112 @property BOOL security;
00113 
00114 @property NSString* authparam;
00115 
00116 @property NSNumber* reconnectionAttempts;
00117 
00118 @property NSNumber* reconnectionDelay;
00119 
00120 @property NSNumber* reconnectionDelayMax;
00121 
00122 
00123 
00124 
00125 
00126 
00127 @property (nonatomic, copy) void (^onCallback)(NSInteger rc, NSString* msg);
00128 @end
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 @interface DPClient : NSObject {
00137 }
00138 
00139 
00140 
00141 
00142 
00143 
00144 + (DPClient *)key:(NSString *)productKey;
00145 
00146 
00147 
00148 
00149 
00150 + (DPClient *)key:(NSString *)productKey options:(DPOptions *)options;
00151 
00152 
00153 @property BOOL isLogging;
00154 
00155 
00156 @property (nonatomic, copy) void (^onConnect)();
00157 
00158 @property (nonatomic, copy) void (^onDisconnect)();
00159 
00160 
00161 - (void)connect;
00162 
00163 - (void)close;
00164 
00165 
00166 
00167 
00168 
00169 - (NSString *)getUserId;
00170 
00171 
00172 
00173 
00174 
00175 - (GroupInfo *)openGroup:(NSString *)groupid;
00176 
00177 
00178 
00179 
00180 
00181 
00182 - (GroupInfo *)openGroup:(NSString *)groupid options:(GroupOptions*)options;
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 - (GroupInfo *)openGroup:(NSString *)groupid options:(GroupOptions*)options callback:(void(^)())callback;
00191 
00192 
00193 
00194 
00195 
00196 - (GroupInfo *)getOpenedGroup:(NSString *)groupid;
00197 
00198 @end
00199 
00200 #endif