mirror of
https://github.com/zhigang1992/FayeObjC.git
synced 2026-01-12 22:47:21 +08:00
Merge branch 'base36_messageids' of git://github.com/steveluscher/FayeObjC into steveluscher-base36_messageids
This commit is contained in:
@@ -69,6 +69,7 @@ enum _fayeStates {
|
||||
BOOL fayeConnected;
|
||||
NSDictionary *connectionExtension;
|
||||
BOOL connectionInitiated;
|
||||
uint32_t messageNumber;
|
||||
}
|
||||
|
||||
@property (strong) NSString *fayeURLString;
|
||||
|
||||
@@ -190,6 +190,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *) base36Encode:(uint32_t)value
|
||||
{
|
||||
NSString *base36 = @"0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
NSString *buffer = @"";
|
||||
|
||||
do {
|
||||
NSString *newChar = [NSString stringWithFormat:@"%c", [base36 characterAtIndex:(value % 36)]];
|
||||
buffer = [newChar stringByAppendingString:buffer];
|
||||
} while (value /= 36);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
- (NSString *) nextMessageId
|
||||
{
|
||||
messageNumber++;
|
||||
if (messageNumber >= UINT32_MAX) messageNumber = 0;
|
||||
|
||||
return [self base36Encode:messageNumber];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark WebSocket connection
|
||||
@@ -293,7 +313,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *messageId = [NSString stringWithFormat:@"msg_%d_%d", (int)[[NSDate date] timeIntervalSince1970], 1];
|
||||
NSString *messageId = [self nextMessageId];
|
||||
NSDictionary *dict = nil;
|
||||
|
||||
if(nil == extension) {
|
||||
|
||||
Reference in New Issue
Block a user