isomorfeus-transport 1.0.0.delta10 → 1.0.0.delta11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f637a7069fc7b858050852ba8f7cd080a4cf7d4159ea2e9fc4d8a9cb494ff1b1
|
4
|
+
data.tar.gz: a2ae36795c32e9cd07120506fee28efdcc454fee98d81d666f717cfea29503d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98bb7ab2ba2ce0323e625344f2af8ade9c3a1429dd7cc0b5657b3aed6f52f39bde20a9a930b955343eceb0f1407f8e4838196fec7500b489fad5ffad0cd1550
|
7
|
+
data.tar.gz: '039b561818a90dc85a0f2accf58b0b007d322441a102c88b7ea17120eb726fd36c4fc1fe2e0f8393c2e9badfa2e7823fbda9f4de97afdf37efe2ce886a81c6db'
|
@@ -2,7 +2,12 @@ module Isomorfeus
|
|
2
2
|
# available settings
|
3
3
|
|
4
4
|
if RUBY_ENGINE == 'opal'
|
5
|
+
def self.add_transport_init_class_name(init_class_name)
|
6
|
+
transport_init_class_names << init_class_name
|
7
|
+
end
|
8
|
+
|
5
9
|
add_client_option(:api_websocket_path)
|
10
|
+
add_client_option(:transport_init_class_names, [])
|
6
11
|
else
|
7
12
|
class << self
|
8
13
|
attr_accessor :api_websocket_path
|
@@ -37,6 +37,10 @@ module Isomorfeus
|
|
37
37
|
@native_websocket.JS[:onmessage] = `function(event) { block.$call(event); }`
|
38
38
|
end
|
39
39
|
|
40
|
+
def on_open(&block)
|
41
|
+
@native_websocket.JS[:onopen] = `function(event) { block.$call(event); }`
|
42
|
+
end
|
43
|
+
|
40
44
|
def send(data)
|
41
45
|
case ready_state
|
42
46
|
when OPEN then @native_websocket.JS.send(data)
|
data/lib/isomorfeus/transport.rb
CHANGED
@@ -8,14 +8,19 @@ module Isomorfeus
|
|
8
8
|
`setTimeout(#{block.to_n}, ms)`
|
9
9
|
end
|
10
10
|
|
11
|
-
def init
|
11
|
+
def init
|
12
12
|
@requests_in_progress = { requests: {}, agent_ids: {} }
|
13
13
|
@socket = nil
|
14
|
-
|
14
|
+
promise_connect if Isomorfeus.on_browser?
|
15
|
+
true
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
|
18
|
+
def promise_connect
|
19
|
+
promise = Promise.new
|
20
|
+
if @socket && @socket.ready_state < 2
|
21
|
+
promise.resolve(true)
|
22
|
+
return promise
|
23
|
+
end
|
19
24
|
if Isomorfeus.on_browser?
|
20
25
|
window_protocol = `window.location.protocol`
|
21
26
|
ws_protocol = window_protocol == 'https:' ? 'wss:' : 'ws:'
|
@@ -34,7 +39,19 @@ module Isomorfeus
|
|
34
39
|
json_hash = `Opal.Hash.$new(JSON.parse(event.data))`
|
35
40
|
Isomorfeus::Transport::ClientProcessor.process(json_hash)
|
36
41
|
end
|
37
|
-
|
42
|
+
@socket.on_open do |event|
|
43
|
+
init_promises = []
|
44
|
+
Isomorfeus.transport_init_class_names.each do |constant|
|
45
|
+
result = constant.constantize.send(:init)
|
46
|
+
init_promises << result if result.class == Promise
|
47
|
+
end
|
48
|
+
if init_promises.size > 0
|
49
|
+
Promise.when(*init_promises).then { promise.resolve(true) }
|
50
|
+
else
|
51
|
+
promise.resolve(true)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
promise
|
38
55
|
end
|
39
56
|
|
40
57
|
def disconnect
|
@@ -44,8 +61,15 @@ module Isomorfeus
|
|
44
61
|
|
45
62
|
def promise_send_path(*path, &block)
|
46
63
|
request = {}
|
47
|
-
|
48
|
-
|
64
|
+
inject_path = path[0...-1]
|
65
|
+
last_inject_path_el = inject_path.last
|
66
|
+
last_path_el = path.last
|
67
|
+
inject_path.inject(request) do |memo, key|
|
68
|
+
if key == last_inject_path_el
|
69
|
+
memo[key] = last_path_el
|
70
|
+
else
|
71
|
+
memo[key] = {}
|
72
|
+
end
|
49
73
|
end
|
50
74
|
Isomorfeus::Transport.promise_send_request(request, &block)
|
51
75
|
end
|
data/lib/isomorfeus-transport.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'opal'
|
2
2
|
require 'opal-autoloader'
|
3
3
|
require 'opal-activesupport'
|
4
|
+
require 'isomorfeus-react'
|
4
5
|
if RUBY_ENGINE == 'opal'
|
5
6
|
require 'json'
|
6
7
|
require 'isomorfeus/config'
|
@@ -14,7 +15,7 @@ if RUBY_ENGINE == 'opal'
|
|
14
15
|
require 'lucid_channel/mixin'
|
15
16
|
require 'lucid_channel/base'
|
16
17
|
Opal::Autoloader.add_load_path('channels')
|
17
|
-
Isomorfeus::Transport
|
18
|
+
Isomorfeus.add_client_init_class_name('Isomorfeus::Transport')
|
18
19
|
else
|
19
20
|
require 'base64'
|
20
21
|
require 'digest'
|
data/lib/lucid_handler/mixin.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-transport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.delta11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 4.0.
|
75
|
+
version: 4.0.11
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 4.0.
|
82
|
+
version: 4.0.11
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: isomorfeus-react
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 16.9.
|
89
|
+
version: 16.9.2
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 16.9.
|
96
|
+
version: 16.9.2
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: websocket-driver
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|