isomorfeus-transport 2.0.7 → 2.0.11

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: 1dc1296b6ffdefe1be0adcb48a10c5ec7311b087963c2ef7c3424917c5e6dbaa
4
- data.tar.gz: 31384438ced13457b8962adc9eb965250d657350d9a124bed644212ff4601d6c
3
+ metadata.gz: bf1dea81493377b7240d5477994ff555232c8820377e00bb82f99e14d0b6bc66
4
+ data.tar.gz: 2ec26078c4781aaf88230e40897b60d972cb5f7033a13d419f25ef1bd568da03
5
5
  SHA512:
6
- metadata.gz: '08584ff6f096caa677e4a84aeeaafe3f13d45eb651a982169e96e6b1914e52a27848cd261d22638b2a3b8e10558db848dff54953cebf16492823dd1746dee426'
7
- data.tar.gz: cca7c4de44c4c6332fddd24666d6edce0c0f8db66a73d95edbe02813bce7d85c7c6f3ac930d459d0fd303513be267b3da56e63bee3aca54fb7769e4df933af13
6
+ metadata.gz: ec77b7733bb07f1f78120ffe2fab9a6dc3fa453fada8b040c8cc1d4be33298f81accc8b3eff6f2ece66af7d6163d333c2b165c852b6d1a9e8e6de52f50f2500b
7
+ data.tar.gz: 7928c27a1ea898df1ca7498d46a8b2c19d3fb08fbde4872de5633a3bea5f26f546cb7a353980a556d34936a9ec6222c81ff9d7a6c28ebc50ae2866a38af263c4
@@ -16,6 +16,7 @@ module Isomorfeus
16
16
  cookie = cookies.detect { |c| c.start_with?('session=') }
17
17
  if cookie
18
18
  session_id = cookie[8..-1]
19
+ return [Anonymous.new, nil] if session_id.nil? || session_id.empty?
19
20
  user = Isomorfeus.session_store.get_user(session_id: session_id)
20
21
  [user, session_id]
21
22
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Transport
3
- VERSION = '2.0.7'
3
+ VERSION = '2.0.11'
4
4
  end
5
5
  end
@@ -11,10 +11,14 @@ module Isomorfeus
11
11
 
12
12
  class SendError < StandardError; end
13
13
 
14
- def initialize(url, protocols = nil)
14
+ def initialize(url, protocols = nil, headers = nil)
15
15
  @url = url
16
- @native_websocket = if protocols
16
+ @native_websocket = if protocols && headers
17
+ `new Opal.global.WebSocket(url, protocols, {headers: #{headers.to_n}})`
18
+ elsif protocols
17
19
  `new Opal.global.WebSocket(url, protocols)`
20
+ elsif headers
21
+ `new Opal.global.WebSocket(url, {headers: #{headers.to_n}})`
18
22
  else
19
23
  `new Opal.global.WebSocket(url)`
20
24
  end
@@ -11,7 +11,7 @@ module Isomorfeus
11
11
  true
12
12
  end
13
13
 
14
- def promise_connect
14
+ def promise_connect(session_id = nil)
15
15
  promise = Promise.new
16
16
  if @socket && @socket.ready_state < 2
17
17
  promise.resolve(true)
@@ -24,7 +24,8 @@ module Isomorfeus
24
24
  else
25
25
  ws_url = "#{Isomorfeus::TopLevel.transport_ws_url}"
26
26
  end
27
- @socket = Isomorfeus::Transport::WebsocketClient.new(ws_url)
27
+ headers = (session_id.nil? || session_id.empty?) ? nil : { 'Cookie': "session=#{session_id}" }
28
+ @socket = Isomorfeus::Transport::WebsocketClient.new(ws_url, nil, headers)
28
29
  @socket.on_error do |error|
29
30
  if Isomorfeus.on_browser?
30
31
  `console.warn('Isomorfeus::Transport: Will try again, but so far error connecting:', error)`
@@ -1,27 +1,27 @@
1
- {
2
- "name": "isomorfeus-transport",
3
- "lockfileVersion": 2,
4
- "requires": true,
5
- "packages": {
6
- "node_modules/ws": {
7
- "version": "8.2.1",
8
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.1.tgz",
9
- "integrity": "sha512-XkgWpJU3sHU7gX8f13NqTn6KQ85bd1WU7noBHTT8fSohx7OS1TPY8k+cyRPCzFkia7C4mM229yeHr1qK9sM4JQ==",
10
- "engines": {
11
- "node": ">=10.0.0"
12
- },
13
- "peerDependencies": {
14
- "bufferutil": "^4.0.1",
15
- "utf-8-validate": "^5.0.2"
16
- },
17
- "peerDependenciesMeta": {
18
- "bufferutil": {
19
- "optional": true
20
- },
21
- "utf-8-validate": {
22
- "optional": true
23
- }
24
- }
25
- }
26
- }
27
- }
1
+ {
2
+ "name": "isomorfeus-transport",
3
+ "lockfileVersion": 2,
4
+ "requires": true,
5
+ "packages": {
6
+ "node_modules/ws": {
7
+ "version": "8.4.2",
8
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz",
9
+ "integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==",
10
+ "engines": {
11
+ "node": ">=10.0.0"
12
+ },
13
+ "peerDependencies": {
14
+ "bufferutil": "^4.0.1",
15
+ "utf-8-validate": "^5.0.2"
16
+ },
17
+ "peerDependenciesMeta": {
18
+ "bufferutil": {
19
+ "optional": true
20
+ },
21
+ "utf-8-validate": {
22
+ "optional": true
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
@@ -1,19 +1,19 @@
1
- Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
1
+ Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.