1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Only open Action Cable connection if data is being sent

This commit is contained in:
Jon Moss 2016-02-24 18:36:55 -05:00
parent 8b69f1eeba
commit 1afd414488
2 changed files with 6 additions and 6 deletions

View file

@ -6,9 +6,11 @@ class ActionCable.Connection
@reopenDelay: 500
constructor: (@consumer) ->
@open()
send: (data) ->
unless @isOpen()
@open()
if @isOpen()
@webSocket.send(JSON.stringify(data))
true

View file

@ -1,11 +1,9 @@
# Action Cable provides the framework to deal with WebSockets in Rails.
# You can generate new channels where WebSocket features live using the rails generate channel command.
#
# Turn on the cable connection by removing the comments after the require statements (and ensure it's also on in config/routes.rb).
#
#= require action_cable
#= require_self
#= require_tree ./channels
#
# @App ||= {}
# App.cable = ActionCable.createConsumer()
@App ||= {}
App.cable = ActionCable.createConsumer()