发送自定义元素后,我断开了连接。有什么办法吗?我的连接代码
[self addDelegate:self delegateQueue:dispatch_get_main_queue()];
[self setHostName"bowerchat.com"];
[self setHostPort:5222];
self.myJID = [XMPPJID jidWithString:[NSString stringWithFormat"%@@bowerchat.com",UD_getObj(@"myPhoneNumber")]];
NSError * error;
[self connectWithTimeout:300 error:&error];
断线问题
Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer"
发现问题后,我将@"type"参数更改为@"type2",现在它正在工作...但我找不到原因?
-(void)sendMessageToServerNSDictionary*)paraDict{
NSString * userPhone = [[DBHelper sharedObject]getUserPhone:paraDict[@"friend_id"]];
NSXMLElement *a = [NSXMLElement elementWithName"request" xmlns"urn:xmpp:receipts"];
if(paraDict[@"type"] != nil){
NSMutableDictionary * k = [[NSMutableDictionary alloc]initWithDictionary:paraDict];
NSString * typeValue = [k[@"type"]copy];
[k removeObjectForKey"type"];
[k setObject:typeValue forKey"type2"];
paraDict = k;
}
XMPPElement *e = [[XMPPElement alloc] initWithName"message"];
for(NSString * key in paraDict.allKeys){
[e addAttributeWithName:key stringValue:paraDict[key]];
}
[e addAttributeWithName"to" stringValue:getJabberString(userPhone)];
[e addAttributeWithName"from" stringValue:getMyJabberString];
[e addChild:a];
NSLog(@"%@",[e attributesAsDictionary]);
[self sendElement:e];
}
消息类型属性内置于 XMPP 协议(protocol)中。它在 XMPP 上具有精确的含义,您不能将所需的内容作为 type 消息属性的值。根据 XMPP RFC 中的定义,唯一可能的类型是:
您不能在消息类型中添加任何内容,或者实际上,否则服务器应该断开您的连接。
引用:http://xmpp.org/rfcs/rfc6121.html#message-syntax-type
关于ios - XMPP IOS Openfire 在发送元素后断开连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31792724/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |