提问人:koil 提问时间:9/12/2023 最后编辑:koil 更新时间:9/12/2023 访问量:31
ActionCable rails 7 无法拦截消息
ActionCable rails 7 unable to intercept message
问:
这是我的视频控制器 #index
ActionCable.server.broadcast("To_User", { body: "This Room is Best Room." })
这是从中流式传输消息的位置。
class ApiUpdateChannel < ApplicationCable::Channel
def subscribed
stream_from "To_User"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
这是我update_api_channel.js
consumer.subscriptions.create({channel: "ApiUpdateChannel", room: "To_User"}, {
connected() {
console.log('blabla')
},
disconnected() {
// Called when the subscription has been terminated by the server
},
received(data) {
console.log('klakla');
}
});
我能够在控制台中看到“blabla”。但是没有“klakla”。我现在被困了一天了。
答: 暂无答案
评论
connect
broadcast
rails assets:clobber
yarn build
received