File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
84
84
NSMutableData *sslReadBuffer;
85
85
size_t sslWriteCachedLength;
86
86
#endif
87
+
88
+ id userData;
87
89
}
88
90
89
91
/* *
@@ -170,6 +172,13 @@ typedef enum GCDAsyncSocketError GCDAsyncSocketError;
170
172
- (BOOL )isIPv4PreferredOverIPv6 ;
171
173
- (void )setPreferIPv4OverIPv6 : (BOOL )flag ;
172
174
175
+ /* *
176
+ * User data allows you to associate arbitrary information with the socket.
177
+ * This data is not used internally by socket in any way.
178
+ **/
179
+ - (id )userData ;
180
+ - (void )setUserData : (id )arbitraryUserData ;
181
+
173
182
#pragma mark Accepting
174
183
175
184
/* *
Original file line number Diff line number Diff line change @@ -1182,6 +1182,35 @@ - (void)setPreferIPv4OverIPv6:(BOOL)flag
1182
1182
}
1183
1183
}
1184
1184
1185
+ - (id )userData
1186
+ {
1187
+ __block id result;
1188
+
1189
+ dispatch_block_t block = ^{
1190
+
1191
+ result = [userData retain ];
1192
+ };
1193
+
1194
+ if (dispatch_get_current_queue () == socketQueue)
1195
+ block ();
1196
+ else
1197
+ dispatch_sync (socketQueue, block);
1198
+
1199
+ return [result autorelease ];
1200
+ }
1201
+
1202
+ - (void )setUserData : (id )arbitraryUserData
1203
+ {
1204
+ dispatch_async (socketQueue, ^{
1205
+
1206
+ if (userData != arbitraryUserData)
1207
+ {
1208
+ [userData release ];
1209
+ userData = [arbitraryUserData retain ];
1210
+ }
1211
+ });
1212
+ }
1213
+
1185
1214
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1186
1215
#pragma mark Accepting
1187
1216
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments