JAXL发送房间消息
使用composer形式安装的JAXL
<?php
require_once "vendor/autoload.php";
$client = new JAXL(array(
'jid' => '',
'pass' => '',
'host'=>'ubuntu',
'auth_type'=>'ANONYMOUS', //匿名登录
'log_level' => JAXLLogger::DEBUG,
));
$_room_full_jid = "test@conference.ubuntu/ordersender";
$room_full_jid = new XMPPJid($_room_full_jid);
$client->require_xep(array(
'0045', // MUC
'0203', // Delayed Delivery
'0199', // XMPP Ping
));
$client->add_cb('on_auth_success', function() {
global $client, $room_full_jid;
// set status
$client->set_status("available!",'dnd',10);
$client->get_vcard(); // fetch your vcard
$client->get_roster(); // fetch your roster list
JAXLLogger::info("got on_auth_success cb, jid ".$client->full_jid->to_string());
JAXLLogger::info("got on_auth_success cb, room_full_jid ".$room_full_jid->to_string());
// join muc room
$client->xeps['0045']->join_room($room_full_jid);
//start send message
//@link http://wiki.jabbercn.org/XEP-0045#.E5.8F.91.E9.80.81.E6.B6.88.E6.81.AF.E7.BB.99.E6.89.80.E6.9C.89.E6.88.BF.E5.AE.A2 例子60的xml格式
//@link JAXL 文档 https://jaxl.readthedocs.io/en/latest/users/xml_objects.html
$xml = new JAXLXml('message');
$_room_full_jid2 = "test@conference.ubuntu";
$to2 = new XMPPJid($_room_full_jid2);
$xml->attrs(array(
'from'=>$client->full_jid->to_string(),
'to'=>$to2->to_string(),
'type'=>'groupchat'
));
$xml->c('body')->t('Hello world');
//xml<message from="244a387a@ubuntu/244a387a" to="test@conference.ubuntu" type="groupchat"><body>Hello world</body></message>
JAXLLogger::info("xml".$xml->to_string());
$client->send($xml); //发送消息
$client->send_end_stream(); //断开连接
});
function on_auth_failure_callback($reason)
{
global $client;
$client->send_end_stream();
JAXLLogger::info("got on_auth_failure cb with reason $reason");
}
$client->add_cb('on_auth_failure', 'on_auth_failure_callback');
function on_disconnect_callback()
{
JAXLLogger::info("got on_disconnect cb");
}
$client->add_cb('on_disconnect', 'on_disconnect_callback');
$client->start();
JAXL发送房间消息的更多相关文章
- JAXL连接Openfire发送房间消息
使用composer形式安装的JAXL <?php require_once "vendor/autoload.php"; $client = new JAXL(array( ...
- ZeroMQ接口函数之 :zmq_msg_send – 从一个socket发送一个消息帧
ZeroMQ 官方地址 :http://api.zeromq.org/4-0:zmq_msg_send zmq_msg_send(3) ØMQ Manual - ØMQ/3.2.5 Name zmq_ ...
- ZeroMQ接口函数之 :zmq_send – 在一个socket上发送一个消息帧
ZeroMQ 官方地址 :http://api.zeromq.org/4-1:zmq-send zmq_send(3) ØMQ Manual - ØMQ/4.1.0 Name ...
- ZeroMQ接口函数之 :zmq_sendmsg – 从一个socket上发送一个消息帧
ZeroMQ 官方地址 :http://api.zeromq.org/4-1:zmq-sendmsg zmq_sendmsg(3) ØMQ Manual - ØMQ/4.1.0 Name ...
- spark结合 Openfire服务器,发送聊天消息
1.下载OpenFire服务器,进行安装,参考http://www.cnblogs.com/hoojo/archive/2012/05/17/2506769.html 2.程序运行客户端:下载客户端代 ...
- Nagios+msn+fetion自定义时间发送报警消息
转自http://blog.csdn.net/deccmtd/article/details/6063467 Nagios+fetion发送手机报警使用了几个月.每次报警短信来都要看下手机.感觉麻烦. ...
- Invalidate(TRUE)与Invalidate(FALSE)区别(前者会发送WM_ERASEBKGND消息全部刷新,然后使用WM_PAINT消息绘制,而后者只发送WM_PAINT消息)
使用Invalidate(TRUE)函数时,它会向消息队列中添加了WM_ERASEBKGND和WM_PAINT两个消息. 使用Invalidate(FALSE)函数时,它只会向消息队列中添加了WM_P ...
- 【Spring】使用Spring和AMQP发送接收消息(上)
讲AMQP之前,先讲下传统的JMS的消息模型,JMS中主要有三个参与者:消息的生产者.消费者.传递消息的通道(队列或者主题),两种消息模型如下:通道是队列: 通道是队列: 通道是主题: 在JMS中,虽 ...
- 微信小程序中发送模版消息注意事项
在微信小程序中发送模版消息 参考微信公众平台Api文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/notice.html#模版消息管理 此参考地址 ...
随机推荐
- as3.0:文字 效果
//文字描边效果var tf1 = _root.createTextField("tf1", _root.getNextHighestDepth(), 10, 10, 0, 0); ...
- chrome浏览器下用jQuery的load函数来跨域加载页面,响应状态status为(canceled)是什么情况? JSON和JSONP,也许你会豁然开朗,含jQuery用例
http://www.cnblogs.com/dowinning/archive/2012/04/19/json-jsonp-jquery.html 问题来源:http://q.cnblogs.com ...
- jquery网页字体变大小
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 一种基于PTP 协议的局域网高精度时钟同步方法(转)
原文地址 http://www.dzsc.com/data/html/2011-1-17/88338.html 1 引言 在分布式系统中, 常常需要一个全局时间, 用来确定系统中各种事件发生的先后.协 ...
- Codeforces Gym 100015G Guessing Game 差分约束
Guessing Game 题目连接: http://codeforces.com/gym/100015/attachments Description Jaehyun has two lists o ...
- hihocoder #1178 : 计数 暴力
#1178 : 计数 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://hihocoder.com/problemset/problem/1178 ...
- SaundProgressBar
https://github.com/eltld/SaundProgressBar
- xmf 翻译
避免在详细信息视图的确认对话框显示? https://documentation.devexpress.com/#Xaf/CustomDocument3160 我如何获得从登录窗口应用程序的数据库? ...
- select,epoll的比较
机制: select:只支持水平触发(数据不处理完无限通知) epoll:支持水平触发和边缘触发(仅通知一次) 单进程监控FD个数 select: 由FD_SETSIZE设置,默认值是2048.在大量 ...
- nopCommerce 数据缓存
为了提高一个系统或网站的性能和IO吞吐量,我们一般都会采用缓存技术.当然NopCommerce也不例外,本文我们就来给大家分析一下nop中Cache缓存相关类设计.核心源码及实现原理. 一.Nop.C ...