我在 Github 上阅读了wiki,第 7 点是这个溃败示例:
Websocket::on('connect', function ($websocket, Request $request) {
// called while socket on connect
$websocket->emit('message', 'hello world');
});
Websocket::on('disconnect', function ($websocket) {
// called while socket on disconnect
});
Websocket::on('example', function ($websocket, $data) {
$websocket->emit('message', 'response from example action');
});
Websocket::on('message', function ($websocket, $data) {
$websocket->emit('message', 'response from message action');
// $websocket->push('message', 'response from message action by push');
});
Websocket::on('test', 'Users/Telegram@connectServers');
Websocket::on('joinToRoom', 'Users/Telegram@joinToRoom');
现在,当它连接时(我用它来测试)只有一条消息hello word
,而我过去发送的每条消息都没有答案。
为什么?
如何在laravel中使用swoole进行正确的路由和控制器?