@@ -8,7 +8,7 @@ module Hyperloop
88
99 class Application
1010 extend React ::IsomorphicHelpers ::ClassMethods
11-
11+
1212 if on_opal_client?
1313 def self . acting_user_id
1414 ClientDrivers . opts [ :acting_user_id ]
@@ -90,7 +90,7 @@ def self.connect_to(channel_name, id = nil)
9090 {
9191 connected: function() {
9292 if (#{ ClientDrivers . env == 'development' } ) { console.log("ActionCable connected to: ", channel_string); }
93- #{ ClientDrivers . get_queued_data ( "connect-to-transport" , channel_string ) }
93+ #{ ClientDrivers . notify_of_connection ( channel_string ) }
9494 },
9595 received: function(data) {
9696 if (#{ ClientDrivers . env == 'development' } ) { console.log("ActionCable received: ", data); }
@@ -181,6 +181,12 @@ class << self
181181 f . when_on_server { ::Rails . env }
182182 end
183183
184+ def self . notify_of_connection ( channel , retries = 10 )
185+ get_queued_data ( 'connect-to-transport' , channel ) . fail do
186+ after ( 0.2 ) { notify_of_connection ( channel , retries - 1 ) } unless retries . zero?
187+ end
188+ end
189+
184190 def self . get_queued_data ( operation , channel = nil , opts = { } )
185191 Hyperloop ::HTTP . get ( polling_path ( operation , channel ) , opts ) . then do |response |
186192 response . json . each do |data |
@@ -208,9 +214,9 @@ def self.initialize_client_drivers_on_boot
208214 @opts = { }
209215
210216 if on_opal_client?
211-
217+
212218 @opts = Hash . new ( `window.HyperloopOpts` )
213-
219+
214220
215221 if opts [ :transport ] == :pusher
216222
0 commit comments