after sending custom element i get disconnected.Is there a way? my code for connection
[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];
disconnected issue
Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer"
After found problem i changed @"type" parameter as @"type2" and it is working now...but i cannot find why?
-(void)sendMessageToServer:(NSDictionary*)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];
}