How to send the status of WebSocket request in ActionCable

痴心易碎 提交于 2019-12-10 16:35:40

问题


Is there any way to send a status of request to client in ActionCable Channels?

For example, if sent data is invalid (or some unknown exception were raised) I want to error text in response message, otherwise send 'status: ok'. What I have on client side now is subscriber's perform method which returns true in almost any circumstances as we can see from source code (github):

send: (data) ->
  if @isOpen()
    @webSocket.send(JSON.stringify(data))
    true
  else
    false

In websocket-rails gem there were methods for this: trigger_failure and trigger_success.

来源:https://stackoverflow.com/questions/39650446/how-to-send-the-status-of-websocket-request-in-actioncable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!