我正在使用库SRWebSocket,我遇到了以下崩溃: 似乎没有循环,除了调用handleMessage的主要SRWebSocket循环:
{"BranchByList":
[
{"id":"342","flag_image":"http:\/\/demo.techzarinfo.com\/newantara\/images\/flags\/USD.png","units":"1","code":"USD B","currency":"US DOLLAR BIG","buy":"4.36","sell":"4.395","updated":"2016-04-11 03:24:24"
},
{"id":"342","flag_image":"http:\/\/demo.techzarinfo.com\/newantara\/images\/flags\/USD.png","units":"1","code":"USD B","currency":"US DOLLAR BIG","buy":"4.36","sell":"4.395","updated":"2016-04-11 03:24:24"
}
]};
首先在SRWebSocket中调用:
Fatal Exception: NSGenericException
*** Collection <_NSFaultingMutableSet: 0x14f60ced0> was mutated while being enumerated.
Fatal Exception: NSGenericException
0 CoreFoundation 0x181e0ae38 __exceptionPreprocess
1 libobjc.A.dylib 0x18146ff80 objc_exception_throw
2 CoreFoundation 0x181e0a86c -[NSException name]
3 Appname 0x1002507b0 -[WebSocketClient notification:] (WebSocketClient.m:534)
4 Appname 0x10024fa68 -[WebSocketClient webSocket:didReceiveMessage:] (WebSocketClient.m:223)
5 Appname 0x10017c260 __30-[SRWebSocket _handleMessage:]_block_invoke (SRWebSocket.m:741)
6 libdispatch.dylib 0x1818554bc _dispatch_call_block_and_release
7 libdispatch.dylib 0x18185547c _dispatch_client_callout
8 libdispatch.dylib 0x18185ab84 _dispatch_main_queue_callback_4CF
9 CoreFoundation 0x181dc0dd8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
10 CoreFoundation 0x181dbec40 __CFRunLoopRun
11 CoreFoundation 0x181ce8d10 CFRunLoopRunSpecific
12 GraphicsServices 0x1835d0088 GSEventRunModal
13 UIKit 0x186fbdf70 UIApplicationMain
14 Appname 0x1003201e4 main (AppDelegate.swift:18)
15 libdispatch.dylib 0x1818868b8 (Missing)
第一个函数调用:
- (void)_handleMessage:(id)message
{
SRFastLog(@"Received message");
[self _performDelegateBlock:^{
[self.delegate webSocket:self didReceiveMessage:message];
}];
}
第二个电话:
- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message
{
NSDictionary *dict = [message objectFromJSONString];
int code = [[dict objectForKey:@"msgCode"] intValue];
MessageType messageType = [[dict objectForKey:@"msgType"] intValue];
if (self.loginBlock != nil && _autoLogining == NO) {
[self feedbackLoginblock:dict];
[self sendToken];
}else{
switch (messageType) {
case MessageTypeReply:
{
NSString *matchIdentify = [dict objectForKey:@"msgId"];
[self checkWaitingBlockQueue:matchIdentify code:code message:dict];
}
break;
case MessageTypeReceiveMessage:{
[self parseReadMessageFeedback:dict];
NSInteger receiveInt = self.receiveNumber.intValue;
receiveInt ++;
self.receiveNumber = [NSNumber numberWithInteger:receiveInt];
}
break;
case MessageTypeAddGroup:{
[self addMemberToGroup:dict];
}
break;
case MessageTypeDeleteGroup:{
[self deleteMemberFromGroup:dict];
}
break;
case MessageTypeNotifyMsgType:{
NSDictionary *content = [dict objectForKey:@"datacontent"];
[self notification:content]; <<< LINE 223
}
}
}
通知更新:方法
- (void)sendMessage:(Message *)message resultBlock:(MessageReplyBlock )block
{
MessageBlock *messageBlock = [self createMessageBlock:block];
[_waitingBlockQueue addObject:messageBlock];
NSNumber *push;
if(message.belongToSession.withSomebody) {
push = [NSNumber numberWithInt:1];
}else{
push = [NSNumber numberWithInt:0];
}
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
messageBlock.matchMessageID, @"matchID",
message.messageType, @"msgType",
message.sourceType, @"msgSourceT",
message.textContent, @"msgTextContent",
_currentUser.contactID, @"from",
push, @"push",
nil];
MessageType messageType = [message.messageType integerValue];
MessageSourceType sourceType = [message.sourceType integerValue];
NSNumber *toContactID = message.toUser.contactID;
if (toContactID == nil) {
return;
}
if ([message.whisperType isEqualToNumber:@1]) {
[dict setObject:@1 forKey:@"option"];
[dict setObject:message.whisperTimeCount forKey:@"msgTimer"];
}
switch (messageType) {
case MessageTypeImage:
{
[dict setObject:message.bigImagePath forKey:@"msgBigsrc"];
[dict setObject:message.smallImagePath forKey:@"msgSmallsrc"]; <<< LINE 534
}
break;
case MessageTypeOfflineAudio:
{
[dict setObject:message.webSourcePath forKey:@"msgUrl"];
[dict setObject:message.voiceTime forKey:@"msgVoiceTime"];
}
break;
case MessageTypeMap:
{
NSString *latitude = [message.latitude stringValue];
NSString *longitude = [message.longitude stringValue];
if (latitude.length > 0 && longitude.length > 0) {
[dict setObject:latitude forKey:@"lat"];
[dict setObject:longitude forKey:@"lng"];
}
}
break;
default:
break;
}
switch (sourceType) {
case MessageSourceTypeP2p:
{
[dict setObject:toContactID forKey:@"to"];
}
break;
case MessageSourceTypeGroup:
{
[dict setObject:toContactID forKey:@"gid"];
}
break;
default:
break;
}
NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:nil];
if(isConnected)
[_webSocket send:data];
else
[self reconnect];
}