在控制台中显示此错误。我不确定,因为!!
[22:52:36] - Zh6YRaL5GA87OcSRAAAG joined channel: publication-channel
[22:52:36] - 9ouEsgJxf3rvG-HHAAAE joined channel: publication-channel
[22:52:36] - evFdvdYHv4FQO6H2AAAF joined channel: publication-channel
[22:52:36] - _v1cF_A4wUctrCz2AAAH joined channel: publication-channel
[22:52:50] - 9ouEsgJxf3rvG-HHAAAE left channel: publication-channel (transport close)
[22:52:50] - Zh6YRaL5GA87OcSRAAAG left channel: publication-channel (transport close)
[22:52:50] - _v1cF_A4wUctrCz2AAAH left channel: publication-channel (transport close)
[22:52:50] - evFdvdYHv4FQO6H2AAAF left channel: publication-channel (transport close)
我在名为Publications的控制器中使用了PublicationWasReceived事件。
event(new PublicationWasReceived($project));
在PublicationWasReceived类中,我从Publications Controller获取数据并创建了一个通道
public function broadcastOn(){
return new Channel('publication-channel');
}
在这里我认为还可以。我想在控制台中显示每个出版物的数据
import Echo from "laravel-echo"
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001'
});
Echo.channel('publication-channel').listen('PublicationWasReceived', (data) => {
console.log(data);
});
Laravel-eco-server中的配置
"authHost": "http://localhost:3000",
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},