作者:软装之家888 | 来源:互联网 | 2023-08-06 18:58
公司决定使用php开发一个客服系统,由于对laravel比较熟,最终决定使用laravelswoolexmpp+openfire开发服务端和客户端。对于swoole,有la
公司决定使用php开发一个客服系统,由于对laravel比较熟,最终决定使用laravel swoole xmpp + openfire开发服务端和客户端。
对于swoole,有laravel-swoole package.
对于xmpp,最终决定使用fabiang/xmpp,原因
demo中只有发送消息的示例,调试OK。
1 2 3 4
| use Fabiang\Xmpp\Options;
$optiOns= new Options($address);
$options->setUsername($username)
->setPassword($password); |
The server address must be in the format tcp://myjabber.com:5222.
If the server supports TLS the connection will automatically be encrypted.
You can also pass a PSR-2-compatible object to the options object:
1
| $options->setLogger($logger) |
The client manages the connection to the Jabber server and requires the options object:
1 2 3 4
| use Fabiang\Xmpp\Client;
$client = new Client($options);
// optional connect manually
$client->connect(); |
For sending data you just need to pass a object that implements FabiangXmppProtocolProtocolImplementationInterface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| use Fabiang\Xmpp\Protocol\Roster;
use Fabiang\Xmpp\Protocol\Presence;
use Fabiang\Xmpp\Protocol\Message;
// fetch roster list; users and their groups
$client->send(new Roster);
// set status to online
$client->send(new Presence);
// send a message to another user
$message = new Message;
$message->setMessage('test')
->setTo('nickname@myjabber.com')
$client->send($message); |
现在的问题是找不到接收消息的代码,请教各位大神,有没有这方面的资料或者链接,给一个demo就行。