如何使用actioncable向发件人客户端回复邮件?

时间:2016-06-03 08:20:51

标签: ruby-on-rails actioncable

在socket.io中,您可以向发件人回复邮件,如:

 socket.on('records', function(sheet_id){
    records = Record.all
    //send message to sender
    socket.emit('records', records);
  });

但是在rails中:

 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

1 个答案:

答案 0 :(得分:4)

使用Excel table image方法

class BoardChannel < ApplicationCable::Channel
  def subscribed
    stream_from "board:#{params[:board]}"
  end

  def speak
    result = do_something()
    transmit(result) # send message to current connection (sender)
  end
end