catapush/xmpp
最新稳定版本:v1.2
Composer 安装命令:
composer require catapush/xmpp
包简介
A client library for talking to XMPP servers.
README 文档
README
Before creating this repository, I've evaluated following XMPP libraries for PHP:
- Nikita's fork, which was based on Alexander's code.
- XMPPHP. There is a better fork made by Charles.
- JAXL.
Unfortunately, none of above ships with what I need. That's the reason I'm creating this repository based on Nikita's work.
Features
- Following features were shipped already from Nikita's fork:
- Connects to and authenticates (using DIGEST-MD5) against XMPP servers (tested against Openfire and jabberd2)
- Supports SSL/TLS connections
- Allows joining of MUC rooms
- Sends messages to individuals and MUC rooms.
- Following features are added by me, plus various refactoring, etc:
- Connects to and authenticates using PLAIN.
- XEP-0045 (Multi-User Chat) related implementations, including to create chatroom, destroy chatroom, grant member, revoke member and get member list.
Sample Code
use Xmpp\Xep\Xep0045; $roomId = 'YourHouse'; $userId = 'Tom'; $options = array( 'username' => 'your_username', 'password' => 'your_password', 'host' => 'example.com', 'ssl' => false, 'port' => 5222, 'resource' => uniqid('', true), 'mucServer' => 'conference.example.com', ); $xmpp = new Xep0045($options, $logger); $xmpp->createRoom($roomId); // Create the room. $xmpp->grantMember($roomId, $userId); // Add a member to the room. $xmpp->getMemberList($roomId); // Get member list and there should be only one member. $xmpp->revokeMember($roomId, $userId); // Remove the only member out from the room. $xmpp->getMemberList($roomId); // Get member list and there should be nobody in the room. $xmpp->destroyRoom($roomId); // Destroy the room. $xmpp->disconnect(); // Disconnect from the server. Important for heavy-loaded servers.
Known Limitations
- Only part of XEP-0045 (Multi-User Chat) protocol extension have been implemented.
- Although code was refactored/written following FIG PSR standards, it was developped and tested for certain project under certain environment only.
Credits
- Nikita's fork.
- Valuable suggestions, helps on performance improments and tests from colleague Jose (known to all as Tachu), Jakub and Jerry.
License
MIT license.
统计信息
- 总下载量: 1.78k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-09