I am working on the Chat concept by using XMPP framework. I am successfully able to make connection with the server. Now my next step is to enter in the given room.
NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
NSString *room = [@"myroom" stringByAppendingString:@"@app.xmpp.syn.in"];
[presence addAttributeWithName:@"to" stringValue:room];
NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"50"];
[x addChild:history];
[presence addChild:x];
XMPPIQ *iq = [XMPPIQ iq];
[iq addChild:presence];
[xmppStream sendElement:presence];
I have tried with the above code but it doesn't work. It doesn't go to following method.
- (void)sendElement:(NSXMLElement *)element
{
if (element == nil) return;
dispatch_block_t block = ^{ @autoreleasepool {
if (state == STATE_XMPP_CONNECTED)
{
[self sendElement:element withTag:TAG_XMPP_WRITE_STREAM];
}
else
{
NSError *error = [NSError errorWithDomain:XMPPStreamErrorDomain
code:XMPPStreamInvalidState userInfo:nil];
[self failToSendElement:element error:error];
}
}};
if (dispatch_get_specific(xmppQueueTag))
block();
else
dispatch_async(xmppQueue, block);
}
I am implementing this very first time. May be I am wrong to enter in the MUC room. Please correct or suggest me with this issue.