action_cable_client 2.0.1 → 2.0.2
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/action_cable_client.rb +12 -4
- data/lib/action_cable_client/message.rb +1 -0
- data/lib/action_cable_client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce107c85e351970c2f8f0b4dec9608c75d78384c
|
4
|
+
data.tar.gz: cff39593ed8b01083d87c438617e3a8d073559db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fa7c5702425a8494356236f444f10403a8f5bd21ae4029b3d3965c08e5f344830ab83dc05573b2ad32c29012820a215aac6383c26c8d61a542f33f6995311d7
|
7
|
+
data.tar.gz: c1f15938485dbe86c96abff5e0b922a4c270400f76d7202cc87e194e6513da934f9f5f467f6778edd960b982f8e22c4f0aa2c19427c3cfa48f4a4917eaeb9827
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 2.0.2
|
2
|
+
|
3
|
+
* [#24](https://github.com/NullVoxPopuli/action_cable_client/pull/24) Fix bug where action cable client is too fast for the server and doesn't wait for the server's welcome message before initiating a channel subscription (@wpp)
|
4
|
+
|
1
5
|
## 2.0.1
|
2
6
|
|
3
7
|
**General**
|
data/lib/action_cable_client.rb
CHANGED
@@ -22,7 +22,7 @@ class ActionCableClient
|
|
22
22
|
attr_reader :_message_factory
|
23
23
|
# The queue should store entries in the format:
|
24
24
|
# [ action, data ]
|
25
|
-
attr_accessor :message_queue, :_subscribed, :
|
25
|
+
attr_accessor :message_queue, :_subscribed, :_subscribed_callback, :_pinged_callback, :_connected_callback
|
26
26
|
|
27
27
|
def_delegator :_websocket_client, :onerror, :errored
|
28
28
|
def_delegator :_websocket_client, :send, :send_msg
|
@@ -91,7 +91,7 @@ class ActionCableClient
|
|
91
91
|
# # do things after the client is connected to the server
|
92
92
|
# end
|
93
93
|
def connected
|
94
|
-
|
94
|
+
self._connected_callback = Proc.new do
|
95
95
|
subscribe
|
96
96
|
yield
|
97
97
|
end
|
@@ -111,7 +111,7 @@ class ActionCableClient
|
|
111
111
|
# # do things after successful subscription confirmation
|
112
112
|
# end
|
113
113
|
def subscribed(&block)
|
114
|
-
self.
|
114
|
+
self._subscribed_callback = block
|
115
115
|
end
|
116
116
|
|
117
117
|
# @return [Boolean] is the client subscribed to the channel?
|
@@ -147,6 +147,8 @@ class ActionCableClient
|
|
147
147
|
|
148
148
|
if is_ping?(json)
|
149
149
|
_pinged_callback&.call(json)
|
150
|
+
elsif is_welcome?(json)
|
151
|
+
_connected_callback&.call(json)
|
150
152
|
elsif !subscribed?
|
151
153
|
check_for_subscribe_confirmation(json)
|
152
154
|
else
|
@@ -162,7 +164,7 @@ class ActionCableClient
|
|
162
164
|
return unless Message::TYPE_CONFIRM_SUBSCRIPTION == message_type
|
163
165
|
|
164
166
|
self._subscribed = true
|
165
|
-
|
167
|
+
_subscribed_callback&.call
|
166
168
|
end
|
167
169
|
|
168
170
|
# {"identifier" => "_ping","message" => 1460201942}
|
@@ -172,6 +174,12 @@ class ActionCableClient
|
|
172
174
|
Message::IDENTIFIER_PING == message_identifier
|
173
175
|
end
|
174
176
|
|
177
|
+
# {"type" => "welcome"}
|
178
|
+
def is_welcome?(message)
|
179
|
+
message_identifier = message[Message::TYPE_KEY]
|
180
|
+
Message::IDENTIFIER_WELCOME == message_identifier
|
181
|
+
end
|
182
|
+
|
175
183
|
def subscribe
|
176
184
|
msg = _message_factory.create(Commands::SUBSCRIBE)
|
177
185
|
send_msg(msg.to_json)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_cable_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- L. Preston Sego III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: websocket-eventmachine-client
|
@@ -117,5 +117,5 @@ rubyforge_project:
|
|
117
117
|
rubygems_version: 2.6.11
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
|
-
summary: ActionCableClient-2.0.
|
120
|
+
summary: ActionCableClient-2.0.2
|
121
121
|
test_files: []
|