Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(void)sendGroupMessage:(Message *)objMessage
- to:(Groups *)objGroups
- {
- // Code by sweeta...
- XMPPJID* recipient = [XMPPJID jidWithString:objGroups.jId];
- XMPPMessage* message = [[XMPPMessage alloc] initWithType:@"groupchat" to:recipient];
- [message addAttributeWithName:@"type" stringValue:@"groupchat"];
- NSMutableDictionary *msgDic = [[NSMutableDictionary alloc] init];
- NSMutableDictionary *senderProperty = [[NSMutableDictionary alloc] init];
- [senderProperty setObject:objGroups.groupName forKey:kGroupName];
- [senderProperty setObject:objGroups.jId forKey:kJId];
- [msgDic setObject:senderProperty forKey:@"sender"];
- [msgDic setObject:[objMessage getDic] forKey:@"message"];
- NSError *err = nil;
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:msgDic options:NSJSONWritingPrettyPrinted error:&err];
- NSString *str = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
- [message addBody:str];
- XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];
- XMPPRoom *xmppRoom = [[XMPPRoom alloc]
- initWithRoomStorage:roomMemoryStorage
- jid:recipient
- dispatchQueue:dispatch_get_main_queue()];
- [xmppRoom sendMessageWithBody:str];
- //
- // NSXMLElement *x = [NSXMLElement elementWithName:@"groupchat" xmlns:XMPPMUCNamespace];
- //
- // XMPPMessage* message = [[XMPPMessage alloc] initWithType:@"groupchat" to:recipient];
- // [message addChild:x];
- // [message addBody:str];
- //
- // [[APP_DELEGATE xmppStream] sendElement:message];
- }
Add Comment
Please, Sign In to add comment