【iOS XMPP】使用XMPPFramewok(四):收发消息
来源:互联网 发布:阿里云ecs远程桌面 编辑:程序博客网 时间:2024/06/07 16:37
原文地址:http://www.cnblogs.com/dyingbleed/archive/2013/05/16/3075105.html
【iOS XMPP】使用XMPPFramewok(四):收发消息
收发消息
接收消息
通过实现
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message;
方法
当接收到 <message /> 标签的内容时,XMPPFramework 框架回调该方法
根据 XMPP 协议,消息体的内容存储在标签 <body /> 内
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message { NSString *messageBody = [[message elementForName:@"body"] stringValue];}
发送消息
发送消息,我们需要根据 XMPP 协议,将数据放到 <message /> 标签内,例如:
<message type="chat" to="xiaoming@example.com">
<body>Hello World!<body />
<message />
- (void)sendMessage:(NSString *) message toUser:(NSString *) user { NSXMLElement *body = [NSXMLElement elementWithName:@"body"]; [body setStringValue:message]; NSXMLElement *message = [NSXMLElement elementWithName:@"message"]; [message addAttributeWithName:@"type" stringValue:@"chat"]; NSString *to = [NSString stringWithFormat:@"%@@example.com", user]; [message addAttributeWithName:@"to" stringValue:to]; [message addChild:body]; [self.xmppStream sendElement:message];}
0 0
- 【iOS XMPP】使用XMPPFramewok(四):收发消息
- 【iOS XMPP】使用XMPPFramewok(四):收发消息
- 【iOS XMPP】使用XMPPFramewok(四):收发消息
- 【iOS XMPP】使用XMPPFramewok(四):收发消息
- 【iOS XMPP】使用XMPPFramewok(四):收发消息
- 【iOS XMPP】使用XMPPFramewok(四):收发消息
- 【iOS XMPP】使用XMPPFramewok(四):收发消息
- ios 使用XMPPFramewok:收发消息
- 【iOS XMPP】使用XMPPFramewok(二):用户登录
- 【iOS XMPP】使用XMPPFramewok(三):好友状态
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(二):用户登录
- 【iOS XMPP】使用XMPPFramewok(三):好友状态
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(二):用户登录
- 【iOS XMPP】使用XMPPFramewok(三):好友状态
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- 【iOS XMPP】使用XMPPFramewok(一):添加XMPPFramework
- HDU 1520 Anniversary party | 树形dp
- drawRect方法
- IP地址与子网划分问题
- Python Client For Redis On Windows
- 两分钟彻底让你明白Android Activity生命周期(图文)
- 【iOS XMPP】使用XMPPFramewok(四):收发消息
- Java 线程池学习--线程池ThreadPoolExecutor使用简介
- JQuery EasyUi之界面设计——前言与界面效果(一)
- 织梦后台登陆不上提示验证码不正确
- JAVA基础知识回顾之---方法中的参数传递
- 【iOS XMPP】使用XMPPFramewok(五):好友列表
- H265 profile
- Linux Mint 16安装 Acrobat reader
- nova中增加数据库表isolated_schedule-openstack-ice