Code Monkey home page Code Monkey logo

laravel-mqtt's Introduction

laravel-MQTT

Simps License PHP Version Swoole Version

使用样例:

$config = [
    'ip' => '0.0.0.0',
    'port' => 8080,
    'callbacks' => [
    ],
    'receiveCallbacks' => [
        \Mqtt\server\MQTT::CONNECT => [\Mqtt\MqttServer::class, 'onMqConnect'],
        \Mqtt\server\MQTT::PINGREQ => [\Mqtt\MqttServer::class, 'onMqPingreq'],
        \Mqtt\server\MQTT::DISCONNECT => [\Mqtt\MqttServer::class, 'onMqDisconnect'],
        \Mqtt\server\MQTT::PUBLISH => [\Mqtt\MqttServer::class, 'onMqPublish'],
        \Mqtt\server\MQTT::SUBSCRIBE => [\Mqtt\MqttServer::class, 'onMqSubscribe'],
        \Mqtt\server\MQTT::UNSUBSCRIBE => [\Mqtt\MqttServer::class, 'onMqUnsubscribe'],
    ],
    'settings' => [
        'worker_num' => 1,
        'open_mqtt_protocol' => true,
    ],
];

Mqtt\AppServer::run($config);

效果:

root@5ef6b759adf0:/var/www/PHP/laravel-MQTT/src/mqtt# php Test.php mqtt:start
                  _   _   
                 | | | |  
  _ __ ___   __ _| |_| |_ 
 | '_ ` _ \ / _` | __| __|
 | | | | | | (_| | |_| |_ 
 |_| |_| |_|\__, |\__|\__|
               | |        
               |_|           Version: 1.0.3
[2020-07-24 17:20:40] [INFO] Swoole MQTT Server runningmqtt://0.0.0.0:8080

安装

可以通过 composer 进行安装。

$ composer require zhangxiuyu/laravel-mqtt

demo在 项目 server/Test.php 文件中 可以根据文件配置 对象

最后执行你的文件即可, 建议放在项目的bin 目录中 命令: php bin/xxx.php mqtt:start

laravel-mqtt's People

Contributors

zhangxiuyu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.