isomorfeus-transport 2.2.8 → 2.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d998320b297b8d6447e640c2dc8dc37e21d33c328518870aae3529683087b67c
4
- data.tar.gz: 52794e70253bd689f3dfce2cf02cdfa8238a44a931fbc51bc81c823ed673f089
3
+ metadata.gz: d2499a5754b1bbc116b2580953d12f3efdbea64ea4d1c042c480125cce3dc46b
4
+ data.tar.gz: 1bd713b1cb253da8a5fd64003e2e446d86fa04f06ff875235bd439ec5d480dea
5
5
  SHA512:
6
- metadata.gz: 7c424f12129f898db1853fdec5c591001568f4a1b4b6042c141310bbeeb462dd4f48ac22bd87f4471b2793dc86f9930683c6a3982f56550cbfdd77d261be91b8
7
- data.tar.gz: 6eb7ab8874202b46fd5afd293ab3b9462350c8b89a5850bae4ea9a2d952172a3195315ae6294b6d1084bab70bedb058332da613ddfe6918a2b78b20da60629e1
6
+ metadata.gz: cb27ae1177bbd4b54220f1fe06b399a7f114d976da5aa75303bcde4ba898bcc0ef1b6a0bc9e1a63eedb0d71ff4ca30e21f11599c3ee83b0745f51228ed1e8e55
7
+ data.tar.gz: 25dd0d1c2bb406003bb9d6a8385ad7ddbeea57aba4ccecace3ce284ae5620b9fa9446529728a2d63cf37dfb6f0a4c7bd72d1003151bedaef26c62f5a723cdfaa
@@ -62,6 +62,7 @@ module Isomorfeus
62
62
  Isomorfeus.current_user_sid = user.sid
63
63
  else
64
64
  @current_user = Anonymous.new
65
+ Isomorfeus.current_user_sid = nil
65
66
  end
66
67
  end
67
68
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Transport
3
- VERSION = '2.2.8'
3
+ VERSION = '2.2.9'
4
4
  end
5
5
  end
@@ -10,13 +10,13 @@ module Isomorfeus
10
10
  true
11
11
  end
12
12
 
13
- def promise_connect(session_id = nil)
14
- promise = Promise.new
13
+ def promise_connect(session_id = nil, promise = nil)
14
+ promise = Promise.new unless promise
15
15
  if @socket && @socket.ready_state < 2
16
16
  promise.resolve(true)
17
17
  return promise
18
18
  end
19
- if Isomorfeus.on_browser?
19
+ if on_browser?
20
20
  window_protocol = `window.location.protocol`
21
21
  ws_protocol = window_protocol == 'https:' ? 'wss:' : 'ws:'
22
22
  ws_url = "#{ws_protocol}//#{`window.location.host`}#{Isomorfeus.api_websocket_path}"
@@ -26,14 +26,15 @@ module Isomorfeus
26
26
  headers = (session_id.nil? || session_id.empty?) ? nil : { 'Cookie': "session=#{session_id}" }
27
27
  @socket = Isomorfeus::Transport::WebsocketClient.new(ws_url, nil, headers)
28
28
  @socket.on_error do |error|
29
- if Isomorfeus.on_browser?
29
+ if on_browser?
30
30
  `console.warn('Isomorfeus::Transport: Will try again, but so far error connecting:', error)`
31
31
  @socket.close
32
32
  after 1000 do
33
- Isomorfeus::Transport.promise_connect
33
+ Isomorfeus::Transport.promise_connect(session_id, promise)
34
34
  end
35
35
  else
36
36
  Isomorfeus.raise_error(message: error.JS[:message], stack: error.JS[:stack])
37
+ promise.reject
37
38
  end
38
39
  end
39
40
  @socket.on_message do |event|
@@ -41,11 +42,16 @@ module Isomorfeus
41
42
  Isomorfeus::Transport::ClientProcessor.process(json_hash)
42
43
  end
43
44
  @socket.on_open do |event|
44
- open_promise = Promise.new.resolve(true)
45
+ init_promises = []
45
46
  Isomorfeus.transport_init_class_names.each do |constant|
46
- result_promise = constant.constantize.send(:init)
47
- open_promise.then { result_promise } if result_promise.class == Promise
47
+ result = constant.constantize.send(:init)
48
+ init_promises << result if result.class == Promise
48
49
  end
50
+ open_promise = if init_promises.size > 0
51
+ Promise.when(*init_promises)
52
+ else
53
+ Promise.new.resolve(true)
54
+ end
49
55
  requests_in_progress[:requests].each_key do |request|
50
56
  agent = get_agent_for_request_in_progress(request)
51
57
  open_promise.then { promise_send_request(request) } if agent && !agent.sent
@@ -101,7 +107,11 @@ module Isomorfeus
101
107
  @socket.close
102
108
  after (Isomorfeus.on_ssr? ? 10 : 3000) do
103
109
  @reconnect = true
104
- Isomorfeus::Transport.promise_connect
110
+ if on_browser?
111
+ Isomorfeus::Transport.promise_connect
112
+ else
113
+ Isomorfeus.raise_error(message: 'Transport lost connection!')
114
+ end
105
115
  end
106
116
  end
107
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-transport
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.8
4
+ version: 2.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
@@ -128,28 +128,28 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 10.6.52
131
+ version: 10.6.54
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 10.6.52
138
+ version: 10.6.54
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: isomorfeus-policy
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 2.2.8
145
+ version: 2.2.9
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 2.2.8
152
+ version: 2.2.9
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: isomorfeus-redux
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -226,14 +226,14 @@ dependencies:
226
226
  requirements:
227
227
  - - '='
228
228
  - !ruby/object:Gem::Version
229
- version: 2.2.8
229
+ version: 2.2.9
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - '='
235
235
  - !ruby/object:Gem::Version
236
- version: 2.2.8
236
+ version: 2.2.9
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: rake
239
239
  requirement: !ruby/object:Gem::Requirement