我已经通过XMPP
框架实现了一个聊天应用程序。但我得到一个错误,如图所示:
xmpp did receive error:-
Printing description of error:
<stream:error xmlns:stream="http://etherx.jabber.org/streams"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams"></conflict><text xmlns="urn:ietf:params:xml:ns:xmpp-streams" lang="">Replaced by new connection</text></stream>
需要有关可能导致此错误的方法以及如何使用
XMPP
重新连接的一些指导。谢谢。
最佳答案
使用XMPPReconnect类。
@property (nonatomic, readonly) XMPPReconnect *xmppReconnect;
self.xmppReconnect = [[XMPPReconnect alloc] init];
[self.xmppReconnect activate:self.xmppStream];
[self.xmppReconnect addDelegate:self delegateQueue:dispatch_get_main_queue()];
并实现“XMPPReconnect”委托(delegate)方法
- (void)xmppReconnect:(XMPPReconnect *)sender didDetectAccidentalDisconnect:(SCNetworkReachabilityFlags)connectionFlags
{
NSLog(@"didDetectAccidentalDisconnect:%u",connectionFlags);
}
- (BOOL)xmppReconnect:(XMPPReconnect *)sender shouldAttemptAutoReconnect:(SCNetworkReachabilityFlags)reachabilityFlags
{
NSLog(@"shouldAttemptAutoReconnect:%u",reachabilityFlags);
return YES;
}