这里我附上了代码:
NSXMLElement *imessage = [NSXMLElement elementWithName:@"message"];
[imessage addAttributeWithName:@"from" stringValue:[[xmppStream myJID]full]];
[imessage addAttributeWithName:@"to" stringValue:roomName];
NSXMLElement *xelem = [NSXMLElement elementWithName:@"x" xmlns:XMPPMUCUserNamespace];
NSXMLElement *decline = [NSXMLElement elementWithName:@"decline"];
[decline addAttributeWithName:@"to" stringValue:roomName];
NSXMLElement *reason = [NSXMLElement elementWithName:@"reason"];
[reason setStringValue:@"Sorry Dear, I can not join right now."];
[decline addChild:reason];
[xelem addChild:decline];
[imessage addChild:xelem];
任何人都可以解决[我的错误]。
答案 0 :(得分:1)
最后我找到了我的问题的答案:
这是我的代码:
NSXMLElement *decline = [NSXMLElement elementWithName:@"decline"];
[decline addAttributeWithName:@"to" stringValue:@"Sender JID"];
if (reason)
{
[decline addChild:reason];
}
NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:XMPPMUCUserNamespace];
[x addChild:decline];
NSXMLElement *message = [XMPPMessage message];
[message addAttributeWithName:@"to" stringValue:Roomname];
[message addChild:x];
[xmppStream sendElement:message];