@@ -8,7 +8,7 @@ module Hyperloop
8
8
9
9
class Application
10
10
extend React ::IsomorphicHelpers ::ClassMethods
11
-
11
+
12
12
if on_opal_client?
13
13
def self . acting_user_id
14
14
ClientDrivers . opts [ :acting_user_id ]
@@ -90,7 +90,7 @@ def self.connect_to(channel_name, id = nil)
90
90
{
91
91
connected: function() {
92
92
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 ) }
94
94
},
95
95
received: function(data) {
96
96
if (#{ ClientDrivers . env == 'development' } ) { console.log("ActionCable received: ", data); }
@@ -181,6 +181,12 @@ class << self
181
181
f . when_on_server { ::Rails . env }
182
182
end
183
183
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
+
184
190
def self . get_queued_data ( operation , channel = nil , opts = { } )
185
191
Hyperloop ::HTTP . get ( polling_path ( operation , channel ) , opts ) . then do |response |
186
192
response . json . each do |data |
@@ -208,9 +214,9 @@ def self.initialize_client_drivers_on_boot
208
214
@opts = { }
209
215
210
216
if on_opal_client?
211
-
217
+
212
218
@opts = Hash . new ( `window.HyperloopOpts` )
213
-
219
+
214
220
215
221
if opts [ :transport ] == :pusher
216
222
0 commit comments