gpt4 book ai didi

ios - XMPPFramework - 如何创建多用户聊天室?

转载 作者:行者123 更新时间:2023-11-29 13:17:08 31 4
gpt4 key购买 nike

如何使用 XMPPFramework 在 iPhone 中实现 GroupChat。我尝试了休闲代码,但未创建房间。我如何知道房间是否已创建。XMPPRoomDelegate 未被调用。当 Stream 断开连接时,调用 handleDidLeaveRoom 方法。任何人都可以帮助我。提前致谢

#define XMPP_HOSTNAME_2  @"chat.someservername.com"
#define XMPP_JID @"venkat@chat.someservername.com"
#define XMPP_PASSWORD @"venkat"
#define ROOM_JID @"venkat_muc@conference.chat.someservername.com/iMac"


- (void)mucSetupStream
{
xmppStream = [[XMPPStream alloc] init];

xmppStream.hostName = XMPP_HOSTNAME_2;
xmppStream.myJID = [XMPPJID jidWithString:XMPP_JID];

[xmppStream addDelegate:self delegateQueue:dispatch_get_main_queue()];

// Configure xmppRoom

XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID];
xmppRoomStorage=[XMPPRoomCoreDataStorage sharedInstance];
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:roomJID dispatchQueue:dispatch_get_current_queue()];

[xmppRoom activate:xmppStream];
[xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];

// Start connection process

NSError *err = nil;
if (![xmppStream connect:&err])
{
DDLogError(@"YapTesting: Cannot connect: %@", err);
}

[self performSelector:@selector(ConfigureNewRoom) withObject:nil afterDelay:5];
}

- (void)ConfigureNewRoom
{
NSLog(@"The Room is Configure After 5 Secs");
[xmppRoom fetchConfigurationForm];
[xmppRoom configureRoomUsingOptions:nil];
}

最佳答案

 [self ConfigureNewRoom];

XMPPRoomMemoryStorage *roomMemoryStorage = [[XMPPRoomMemoryStorage alloc] init];

XMPPRoom *xmppRoom1 = [[XMPPRoom alloc] initWithRoomStorage:roomMemoryStorage jid:[XMPPJID jidWithString:@"Fun@conference.server.com"] dispatchQueue:dispatch_get_main_queue()];

[xmppRoom1 activate:[self xmppStream]];

[xmppRoom1 joinRoomUsingNickname:@"Fun" history:nil];
[xmppRoom1 addDelegate:self delegateQueue:dispatch_get_main_queue()];
[xmppRoom1 fetchConfigurationForm];
[xmppRoom1 configureRoomUsingOptions:nil];

关于ios - XMPPFramework - 如何创建多用户聊天室?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15448784/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com