在 socket.io 中,您可以向发件人回复消息,例如:
socket.on('records', function(sheet_id){
records = Record.all
//send message to sender
socket.emit('records', records);
});
但在导轨中:
class BoardChannel < ApplicationCable::Channel
def subscribed
stream_from "board:#{params[:board]}"
end
def speak
# client will call @perform('speak')
result = do_something()
# how to send 'result' to sender?
end
end