Code Monkey home page Code Monkey logo

mqtt's People

Contributors

anoxia avatar manhere avatar maoxp avatar mouyong avatar walkor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mqtt's Issues

连续new 两个对象会报错

连续new 两个对象会报错
for($i=0;$i<2;$i++){
$mqtt = new Workerman\Mqtt\Client(...)
}

PHP Warning: Cannot declare class \Workerman\Protocols\Mqtt, because the name is already in use in

How to set QoS on Subscribe

For Subscribe how do i set QoS => 1 on $option?

$mqtt = new Workerman\Mqtt\Client($mqtt_link, array( 'debug' => true, 'clean_session' => false, 'qos' => 1, "client_id" => "mqtt-client-cronjob", "username" => $mqtt_user, "password" => $mqtt_pass ));

but i got qos:0 on return

How to disconnect inside a Chat client?

I've altered the chatroom example to let the user exit the chatroom:

        $console = new TcpConnection(STDIN);
        $console->onMessage = function($console, $message) use ($mqtt){
            $message=trim($message);
            if ($message=="exit") {
                $mqtt->disconnect();
                die;
            } else {
                $mqtt->publish('testRoom', $message);
            }
        };

When the user enters "exit" I want the worker to stop but it reconnects always. I've tried using "$mqtt->doNotReconnect=true;" but it doesn't work.
Anyone knows how to do this?

it works fine in examples but can not subscribe the 'test' topic in laravel command

`public function handle()
{
global $argv;
$action = $this->argument('action');
if (!in_array($action, ['start', 'stop'])) {
$this->error('Error Arguments');
exit;
}
$argv[0] = 'workerman:httpserver';
$argv[1] = $action;
$argv[2] = $this->option('daemonize') ? '-d' : '';
$worker = new Worker();
$worker->onWorkerStart = function () {
// $mqtt = new Client('mqtt://192.168.0.247:1883');
$mqtt = new \Workerman\Mqtt\Client('mqtt://192.168.0.247:1883');
Log::info(1);
$mqtt->onConnect = function ($mqtt) {
$mqtt->subscribe('test');
$this->info(2);
};
$mqtt->onMessage = function ($topic, $content) {
var_dump($topic, $content);
$this->info($content);
};
};
Worker::runAll();

}`

Deamon mode not working in codeigniter framework

I have integrated workerman mqtt in the CodeIgniter framework.

I am running the code from the terminal as following:
php index.php controller function start

In the function, I have added the workerman mqtt code. I have to change the argument key for command in "Worker.php" file as following:

$command  = trim($argv[3]);
$command2 = isset($argv[4]) ? $argv[4] : '';

Replaced $argv[1] with $argv[3] and $argv[2] with $argv[4]. It is working fine.

When I run php index.php controller function start -d, The code that I put into onMessage function is not working. Which is working fine in DEBUG mode.

Following is the output when I run in DEAMON mode

Workerman[index.php] start in DAEMON mode
------------------------------------- WORKERMAN --------------------------------------
Workerman version:3.5.19 PHP version:7.1.25
-------------------------------------- WORKERS ---------------------------------------
proto user worker listen processes status
tcp bitnami none none 1 [OK]

Input "php index.php stop" to stop. Start success.

How to publish message with out the loop?

Hello! I am using bunny to work with RabbitMQ, the code is:

$client = (new Bunny\Client())->connect()->channel();
// ...
$channel->run(function(Message $message, Channel $channel, Client $client) {
	// --> here i need to send a message to MQTT broker;
}, 'hello', '', FALSE, TRUE);

It is infinite loop, so i need to send message and return to loop, is it possible?

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.