I started with xmppframework recently, but I am stuck in a problem. I can connect to my server on my local network, but the xmppstreamdelegate methods do not receive a call in my user class, but work fine on the appdelegate class. Can anyone help me on this. Or did the delegate only support the appdelegate class?
Title:
@interface XmppClass : NSObject<XMPPStreamDelegate>{ XMPPStream *xmppStream; Login * loginDetail; BOOL allowSelfSignedCertificates; BOOL allowSSLHostNameMismatch; } @property (nonatomic, strong, readonly) XMPPStream *xmppStream; @property (nonatomic, strong) Login *loginDetail; - (id)initWithLogin:(Login *) loginrefernce; - (BOOL)connect; - (void)disconnect; - (void)setupStream; @end
Implementation:
@implementation XmppClass @synthesize xmppStream; @synthesize loginDetail; - (id)initWithLogin:(Login *) loginrefernce { self = [super init]; if (self) { self.loginDetail=loginrefernce; [DDLog addLogger:[DDTTYLogger sharedInstance]]; [self setupStream]; [self connect]; } return self; } - (void)setupStream { NSAssert(xmppStream == nil, @"Method setupStream invoked multiple times"); // Setup xmpp stream // // The XMPPStream is the base class for all activity. // Everything else plugs into the xmppStream, such as modules/extensions and delegates. xmppStream = [[XMPPStream alloc] init];
}
- (void)xmppStreamDidSecure:(XMPPStream *)sender { DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); } - (void)xmppStreamDidConnect:(XMPPStream *)sender { DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); NSLog(@"connected"); NSError *error = nil; if (![[self xmppStream] authenticateWithPassword:self.loginDetail.password error:&error]) { DDLogError(@"Error authenticating: %@", error); } } - (void)xmppStreamDidAuthenticate:(XMPPStream *)sender { DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); NSLog(@"authenticated"); } - (void)xmppStream:(XMPPStream *)sender didNotAuthenticate:(NSXMLElement *)error { DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); NSLog(@"did not authenticate"); } - (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq { DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD); return NO; } - (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message { DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
Suhas_United
source share