Skip to content

easy-swoole/mqtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

设计思路

EventInterface 定义了MQTT的全部事件,而Event实现了这个接口,并实现了部分默认功能

测试服务端

use EasySwoole\MQTT\MQTT;
use EasySwoole\MQTT\Event;
use EasySwoole\MQTT\Protocol\Message;

$server = new swoole_server("127.0.0.1", 9600);

$server->set([
    'open_mqtt_protocol'=>true
]);

$mqtt = new MQTT();
/*
 * 事件注册
 */
$mqtt->event()->set(Event::CONNECT,function (Message $message,int $fd){
    /*
     * 若握手成功返回Reply
     */
});

$mqtt->attachServer($server);

$server->on('close', function ($server, $fd) {
    echo "connection close: {$fd}\n";
});
$server->start();

参考文献

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages