gpt4 book ai didi

ios - 如何使用 xmppframework 创建一个新的聊天组?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:46:24 26 4
gpt4 key购买 nike

您好,我正在 IOS 中开发一个聊天应用程序并完成了一对一聊天,在搜索了很多有关 groupChat 的信息后,无法了解如何在 xmppframework 中创建一个普通的组。

我已经在这里尝试过的是一个链接

iOS XMPP group chat implementation

Accepting chatroom invitation

How to create MultiUserChatRoom using XMPPFramework in iPhone

XMPPFramework - How to Create a MultiUserChat Rooms?

但是没有从上面的这些链接中得到任何积极的回应,

在编码方面我尝试过

XMPPRoomCoreDataStorage *rosterstorage = [[XMPPRoomCoreDataStorage alloc] init];
XMPPRoom *xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:rosterstorage jid:[XMPPJID jidWithString:@"test@conference.domainName.com/rohit"] dispatchQueue:dispatch_get_main_queue()];
[xmppRoom configureRoomUsingOptions:nil];
[xmppRoom activate:[self xmppStream]];
[xmppRoom addDelegate:self
delegateQueue:dispatch_get_main_queue()];
[xmppRoom inviteUser:[XMPPJID jidWithString:@"abc@domainName.com"] withMessage:@"Hi join room"];

还有这个

- (void)createOrEnterRoom:(NSString *)roomName
{
//here we enter a room, or if the room does not yet exist, this method creates it
//per XMPP documentation: "If the room does not yet exist, the service SHOULD create the room"
//this method accepts an argument which is what you would baptize the room you wish created
XMPPPresence *presence = [XMPPPresence presence];
NSString *room = [roomName stringByAppendingString:@"@conference.domain.com"];
[presence addAttributeWithName:@"to" stringValue:room];
NSXMLElement *x = [NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];
NSXMLElement *history = [NSXMLElement elementWithName:@"history"];
[history addAttributeWithName:@"maxstanzas" stringValue:@"50"];
[x addChild:history];
[presence addChild:x];
[[self xmppStream] sendElement:presence];
}

最后一个是

-(void)createGroup
{
@try {
NSString *username=@"user_3";//[self.userDefault valueForKey:@"userid"];

NSXMLElement *presenceElement=[NSXMLElement elementWithName:@"presence"];

[presenceElement addAttributeWithName:@"type" stringValue:@"groupchat"];

[presenceElement addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@%@",username,HostName]];

[presenceElement addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"testGroup@conference.%@/%@",HostName,username]];

NSXMLElement *xElement=[NSXMLElement elementWithName:@"x" xmlns:@"http://jabber.org/protocol/muc"];

NSXMLElement *historyElement=[NSXMLElement elementWithName:@"history"];

[xElement addChild:historyElement];

[presenceElement addChild:xElement];

[self.xmppStream sendElement:presenceElement];
}
@catch (NSException *exception) {
}


}

任何人请告诉我解决此问题的方法。如果我们需要在 ejjabered 配置中配置一些额外的东西,也请告诉我。

最佳答案

请仔细阅读我在这里找到的最佳和详细答案。

Trouble creating xmpp muc room: Code 503 (service unavailable)

关于ios - 如何使用 xmppframework 创建一个新的聊天组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22964660/

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