XMPPFramework - 如何创建MUC房间并邀请用户?
我正在使用 Robbiehanson 的 iOS XMPPFramework。我正在尝试创建一个 MUC 房间并邀请用户加入群聊房间,但它不起作用。
我使用以下代码:
XMPPRoom *room = [[XMPPRoom alloc] initWithRoomName:@"[email protected]/room" nickName:@"room"];
[room createOrJoinRoom];
[room sendInstantRoomConfig];
[room setInvitedUser:@"[email protected]"];
[room activate:[self xmppStream]];
[room inviteUser:jid1 withMessage:@"hello please join."];
[room sendMessage:@"HELLO"];
用户 [email protected] 应该收到邀请消息但什么也没有发生。
任何帮助将不胜感激。 :)
I am using Robbiehanson's iOS XMPPFramework. I am trying to create a MUC room and invite a user to the group chat room but it is not working.
I am using the following code:
XMPPRoom *room = [[XMPPRoom alloc] initWithRoomName:@"[email protected]/room" nickName:@"room"];
[room createOrJoinRoom];
[room sendInstantRoomConfig];
[room setInvitedUser:@"[email protected]"];
[room activate:[self xmppStream]];
[room inviteUser:jid1 withMessage:@"hello please join."];
[room sendMessage:@"HELLO"];
The user [email protected] should receive the invite message but nothing is happening.
Any help will be appreciated. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在探索了各种解决方案之后,我决定在这里编译并分享我的实现:
创建 XMPP Room:
检查该委托中是否成功创建房间:
检查您是否已加入此委托中的房间:
创建房间后,获取房间配置表单:
配置你的房间
<前><代码>/**
* 防止此消息所必需的:
*“在确认配置之前,该房间将被锁定,无法进入。”
*/
- (void)xmppRoom:(XMPPRoom *)发送者 didFetchConfigurationForm:(NSXMLElement *)configForm
{
NSXMLElement *newConfig = [configForm 副本];
NSArray *fields = [newConfig elementsForName:@"field"];
for (NSXMLElement *字段中的字段)
{
NSString *var = [字段 attributeStringValueForName:@"var"];
// 使空间持久化
if ([var isEqualToString:@"muc#roomconfig_persistentroom"]) {
[字段removeChildAtIndex:0];
[字段 addChild:[NSXMLElement elementWithName:@"value" stringValue:@"1"]];
}
}
[发送者configureRoomUsingOptions:newConfig];
}
参考文献:XEP-0045:多用户聊天,< a href="https://stackoverflow.com/questions/19268629/xmpp-ios-chat-client-implement-group-chat">实施组聊天
邀请用户
在这里,您创建了一个 XMPP 多用户/群组聊天室,并邀请了一位用户。 :)
After exploring various solutions, I've decided to compile and share my implementation here:
Create an XMPP Room:
Check if room is successfully created in this delegate:
Check if you've joined the room in this delegate:
After room is created, fetch room configuration form:
Configure your room
References: XEP-0045: Multi-User Chat, Implement Group Chat
Invite users
There, you've created a XMPP multi-user/group chat room, and invited a user. :)
我感觉alloc-init之后要做的第一件事就是将它附加到你的xmppStream,这样它就可以使用xmppStream发送/接收消息。
更准确地说:
I have the feeling that the first thing to do after alloc-init is to attach it to your xmppStream, so it can use xmppStream to send/receive messages.
More exactly:
检查最新的XMPPMUCLight & XMPPRoomLight 与 Whatsapp 和其他当今流行的社交应用程序房间类似,离线或房间里无人时不会被破坏或成员被踢。
请参阅此文档 & 来自 MongooseIM 的模组
Check the latest XMPPMUCLight & XMPPRoomLight its similar to Whatsapp and other today's trends social app rooms that don't get destroyed or members kicked when offline or no one in room.
Refer this documentation & mod from MongooseIM