使用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发送房间消息的更多相关文章

  1. JAXL连接Openfire发送房间消息

    使用composer形式安装的JAXL <?php require_once "vendor/autoload.php"; $client = new JAXL(array( ...

  2. 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_ ...

  3. ZeroMQ接口函数之 :zmq_send – 在一个socket上发送一个消息帧

    ZeroMQ 官方地址 :http://api.zeromq.org/4-1:zmq-send zmq_send(3)              ØMQ Manual - ØMQ/4.1.0 Name ...

  4. ZeroMQ接口函数之 :zmq_sendmsg – 从一个socket上发送一个消息帧

    ZeroMQ 官方地址 :http://api.zeromq.org/4-1:zmq-sendmsg zmq_sendmsg(3)        ØMQ Manual - ØMQ/4.1.0 Name ...

  5. spark结合 Openfire服务器,发送聊天消息

    1.下载OpenFire服务器,进行安装,参考http://www.cnblogs.com/hoojo/archive/2012/05/17/2506769.html 2.程序运行客户端:下载客户端代 ...

  6. Nagios+msn+fetion自定义时间发送报警消息

    转自http://blog.csdn.net/deccmtd/article/details/6063467 Nagios+fetion发送手机报警使用了几个月.每次报警短信来都要看下手机.感觉麻烦. ...

  7. Invalidate(TRUE)与Invalidate(FALSE)区别(前者会发送WM_ERASEBKGND消息全部刷新,然后使用WM_PAINT消息绘制,而后者只发送WM_PAINT消息)

    使用Invalidate(TRUE)函数时,它会向消息队列中添加了WM_ERASEBKGND和WM_PAINT两个消息. 使用Invalidate(FALSE)函数时,它只会向消息队列中添加了WM_P ...

  8. 【Spring】使用Spring和AMQP发送接收消息(上)

    讲AMQP之前,先讲下传统的JMS的消息模型,JMS中主要有三个参与者:消息的生产者.消费者.传递消息的通道(队列或者主题),两种消息模型如下:通道是队列: 通道是队列: 通道是主题: 在JMS中,虽 ...

  9. 微信小程序中发送模版消息注意事项

    在微信小程序中发送模版消息 参考微信公众平台Api文档地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/notice.html#模版消息管理 此参考地址 ...

随机推荐

  1. 负载均衡SESSION同步总结

    1.redis/分布式文件存储系统/数据库 存储session,解决负载均衡集群中session不一致问题 http://www.cnblogs.com/painsOnline/p/5194851.h ...

  2. cocos2d_x iconv转码

    作者:何卫 转载请注明,原文链接:http://www.cnblogs.com/hewei2012/p/3374147.html iconv下载(Android) 源码下载地址,已编译完的iconv包 ...

  3. 将Excel另存为CSV格式文件

    直接将Excel另存为CSV,速度很快: $CurrentPath = $MyInvocation.MyCommand.Path.substring(0,$MyInvocation.MyCommand ...

  4. Windows常用性能计数器总结

    基础监控: Processor:% Processor Time CPU当前利用率,百分比 Memory:Available MBytes 当前可用内存,兆字节(虚拟内存不需要监控,只有当物理内存不够 ...

  5. 使用Machin公式计算

    使用Machin公式计算,并使用百亿进制+末项位数控制,这里可算出数万位(比最简PI快80倍),源代码约40行,在本网页中. 计算公式 PI=16arctg(1/5)-4arctg(1/239),其中 ...

  6. UITableViewCell重用机制

    UITableView是iOS开发中使用频率非常高的一个控件,它常被用来展示信息列表,尽管信息数据可能非常多,但UITableView消耗的资源却并不会随着展示信息的增多而变大,这都要得益于UITab ...

  7. opencv china 网站,好1376472449

    http://www.opencvchina.com/thread-1750-1-2.html

  8. FluorineFx对于现有站点的配置

    step 1:新建一个FluorineFX网站,作为参考 step 2:在现有网站添加FluorineFX网站的相关dll引用,并拷贝console.aspx和gateway.aspx至网站根目录(最 ...

  9. [Angular2 Router] CanActivate Route Guard - An Example of An Asynchronous Route Guard

    In this tutorial we are going to learn how we can to configure an can activate route guard in the An ...

  10. [Angular2 Router] Lazy Load Angular 2 Modules with the Router

    Angular 2 lazy loading is a core feature of Angular 2. Lazy loading allows your application to start ...