iOS XMPP群聊方法的实现
来源:互联网 发布:淘宝开店半年怎么算 编辑:程序博客网 时间:2024/06/13 12:20
首先需要创建一个房间:
xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:[XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@", jidString, @"conference.192.168.1.117"]]]; [xmppRoom activate:xmppStream]; [xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()];
加入房间:
[[self xmppRoom] joinRoomUsingNickname:[[[NSUserDefaults standardUserDefaults] objectForKey:@"UserInfo"] valueForKey:@"userId"] history:nil];
此时房间ID就出现在好友列表内,可以正常进入聊天。
其次邀请好友:
[[self xmppRoom] inviteUser:[XMPPJID jidWithString:[NSString stringWithFormat:@"%@@192.168.1.117", friendIDFeild.text]] withMessage:@"join room!"];
客户端要对收到邀请做出响应,方法如下:
新建一个XMPPMUC:
xmppMUC = [[XMPPMUC alloc] initWithDispatchQueue:dispatch_get_main_queue()]; [xmppMUC activate:xmppStream]; [xmppMUC addDelegate:self delegateQueue:dispatch_get_main_queue()];类要实现XMPPMUCDelegate
-(void)xmppMUC:(XMPPMUC *)sender roomJID:(XMPPJID *)roomJID didReceiveInvitation:(XMPPMessage *)message{ NSLog(@"%@", message); xmppRoom = [[XMPPRoom alloc] initWithRoomStorage:self jid:roomJID]; [xmppRoom activate:xmppStream]; [xmppRoom addDelegate:self delegateQueue:dispatch_get_main_queue()]; [xmppRoom joinRoomUsingNickname:[[[NSUserDefaults standardUserDefaults] objectForKey:@"UserInfo"] valueForKey:@"userId"] history:nil];}其中
[xmppRoom joinRoomUsingNickname:[[[NSUserDefaults standardUserDefaults] objectForKey:@"UserInfo"] valueForKey:@"userId"] history:nil];
为确认加入房间。
当你接受请求后,房间id会出现在联系人列表中,正常聊天就可以了,聊天信息的type为groupchat,这部分在XMPP基础中有,不做赘述。此为初步,后续补充。
0 0
- iOS XMPP群聊方法的实现
- XMPP的iOS聊天客户端-实现群聊
- 基于XMPP协议的IOS实现(二)XMPP解析
- 基于XMPP的IOS实现单聊,群聊功能(一)
- 基于XMPP的IOS实现单聊,群聊功能(二)
- iOS客户端实现 XMPP协议的步骤
- ios开发-XMPP功能的实现
- iOS XMPP简单聊天的实现
- iOS 实现XMPP协议
- IOS XMPP 实现
- IOS XMPP的实践
- IOS XMPP的实践
- IOS XMPP的实践
- IOS XMPP的实践
- IOS XMPP的实践
- iOS xmpp的使用
- IOS XMPP的实践
- IOS XMPP的实践
- leetcode 刷题之路 86 Remove Element
- Android Camera开发:给摄像头预览界面加个ZoomBar(附完整代码下载)
- [学习小结]Activiti5 流程规则管理
- Facebook移动开源项目大合集
- WordPress过滤器(Filters):apply_filters和add_filter
- iOS XMPP群聊方法的实现
- 数据的存储与传输
- android SDK总是更新失败怎么办
- Struts2深入学习----OGNL表达式原理
- Localizable.strings 文件
- Java中的final和向上转型
- html中二级菜单的制作
- JAVA安装,环境变量配置
- HDU 1597 find the nth digit 找规律