首页 > 代码库 > xmpp聊天室(5)
xmpp聊天室(5)
聊天室
[cpp] view plaincopyprint?
- //初始化聊天室
- XMPPJID *roomJID = [XMPPJID jidWithString:ROOM_JID];
- xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:roomJID];
- [xmppRoom activate:xmppStream];
- [xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
[cpp] view plaincopyprint?
- //创建聊天室成功
- - (void)xmppRoomDidCreate:(XMPPRoom *)sender
- {
- DDLogInfo(@"%@: %@", THIS_FILE, THIS_METHOD);
- }
[cpp] view plaincopyprint?
- //加入聊天室,使用昵称
- [xmppRoom joinRoomUsingNickname:@"quack" history:nil];
[cpp] view plaincopyprint?
- //获取聊天室信息
- - (void)xmppRoomDidJoin:(XMPPRoom *)sender
- {
- [xmppRoom fetchConfigurationForm];
- [xmppRoom fetchBanList];
- [xmppRoom fetchMembersList];
- [xmppRoom fetchModeratorsList];
- }
如果房间存在,会调用委托
[cpp] view plaincopyprint?
- // 收到禁止名单列表
- - (void)xmppRoom:(XMPPRoom *)sender didFetchBanList:(NSArray *)items;
- // 收到好友名单列表
- - (void)xmppRoom:(XMPPRoom *)sender didFetchMembersList:(NSArray *)items;
- // 收到主持人名单列表
- - (void)xmppRoom:(XMPPRoom *)sender didFetchModeratorsList:(NSArray *)items;
房间不存在,调用委托
[cpp] view plaincopyprint?
- - (void)xmppRoom:(XMPPRoom *)sender didNotFetchBanList:(XMPPIQ *)iqError;
- - (void)xmppRoom:(XMPPRoom *)sender didNotFetchMembersList:(XMPPIQ *)iqError;
- - (void)xmppRoom:(XMPPRoom *)sender didNotFetchModeratorsList:(XMPPIQ *)iqError;
离开房间
[cpp] view plaincopyprint?
- [xmppRoom deactivate:xmppStream];
[cpp] view plaincopyprint?
- //离开聊天室
- - (void)xmppRoomDidLeave:(XMPPRoom *)sender
- {
- DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
- }
其他代理
[cpp] view plaincopyprint?
- //新人加入群聊
- - (void)xmppRoom:(XMPPRoom *)sender occupantDidJoin:(XMPPJID *)occupantJID
- {
- DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
- }
- //有人退出群聊
- - (void)xmppRoom:(XMPPRoom *)sender occupantDidLeave:(XMPPJID *)occupantJID
- {
- DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
- }
- //有人在群里发言
- - (void)xmppRoom:(XMPPRoom *)sender didReceiveMessage:(XMPPMessage *)message fromOccupant:(XMPPJID *)occupantJID
- {
- DDLogVerbose(@"%@: %@", THIS_FILE, THIS_METHOD);
- }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。