php 发送ws 消息,php – Ratchet WebSocket – 立即发送消息
发布日期:2021-06-24 11:36:47 浏览次数:3 分类:技术文章

本文共 686 字,大约阅读时间需要 2 分钟。

我必须在发送消息之间进行一些复杂的计算,但是第一个消息在执行后以秒发送.我该如何立即发送?

namespace AppBundle\WSServer;

use Ratchet\MessageComponentInterface;

use Ratchet\ConnectionInterface;

class CommandManager implements MessageComponentInterface {

public function onOpen(ConnectionInterface $conn) {

//...

}

public function onClose(ConnectionInterface $connection) {

//...

}

public function onMessage(ConnectionInterface $connection, $msg) {

//...

$connection->send('{"command":"someString","data":"data"}');

//...complicated compulting

sleep(10);

//send result

$connection->send('{"command":"someString","data":"data"}');

return;

}

}

启动服务器:

$server = IoServer::factory(

new HttpServer(

new WsServer(

$ws_manager

)

), $port

);

转载地址:https://blog.csdn.net/weixin_32541663/article/details/116410081 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:oracle多sid,oracle相同SID对外提供多个service_names
下一篇:oracle 7 密码,【翻译自mos文章】重置Oracle Linux 7中root的口令

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月20日 21时58分13秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章