Comments (6)
现在的就是一一对应的,没使用channel。
from mqtt.
那也就会导致,监听消息之后。 没法再订阅,发布等操作了。
from mqtt.
这看你代码怎么写了
from mqtt.
\Hyperf\Utils\Coroutine::create(function() use($timeSincePing) {
try {
$client = $this->client();
while($this->running){
$buffer = $client->recv();
if ($buffer && $buffer !== true) {
$timeSincePing = time();
$this->onMessage($buffer);
}
if ($timeSincePing <= (time() - $client->getConfig()->getKeepAlive())) {
$buffer = $client->ping();
if ($buffer) {
$this->write('ping success');
$timeSincePing = time();
} else {
$client->close();
break;
}
}
}
} catch (\Throwable $th) {
$this->write('recv coroutine has error: ' . $th->getMessage());
}
});
我目前只是再协程中 while true 简单的实现了一下。
如果大佬有时间 看能不能 提供个例子参考。
from mqtt.
你用channel也行的,看下这两个吧 hyperf/hyperf#3260 hyperf/hyperf#3026
from mqtt.
ok, thx.
from mqtt.
Related Issues (20)
- 完善Properties
- [QUESTION] Installation failed HOT 2
- [BUG] composer 1.1.2版本 发生了重连之后就接收不到监听 HOT 3
- 建议增加docker部署 HOT 1
- [BUG] recv 重连问题 HOT 7
- [BUG]订阅过程的keepalive的ping包无法发送 HOT 1
- [BUG]无论publish的qos级别是多少,订阅到的结果都是qos=0 HOT 5
- [QUESTION]订阅topic10个左右,无论是使用通配符还是一条一条订阅,都只能收到3个左右的topic消息 HOT 2
- [QUESTION] Send message to specific subscribers HOT 1
- Can this project be used for implementing an MQTT server? HOT 3
- 断线重连时,能不能把首次连接时相关的操作再进行一次初始化,比如订阅的主题 HOT 1
- [QUESTION] clean_session开启后 重连恢复订阅的问题 HOT 1
- Uncaught Error: Call to undefined function Swoole\Coroutine\run() HOT 7
- PUBLISH with not enough remaining read buffer length was sent. HOT 6
- [QUESTION] 请问支持基于websocket的mqtt客户端吗? HOT 3
- [QUESTION] HOT 4
- [QUESTION] HOT 6
- [QUESTION]send方法中response默认值为true,当用协程去处理recv消息时会跟simps中的协程冲突导致报错 HOT 1
- [BUG] HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt.