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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4085894ce47fa6d116953ecdaf16770f7849cb27
4
- data.tar.gz: 654c166304ca757a36fd0c4d3755ee132fdbe497
3
+ metadata.gz: ce107c85e351970c2f8f0b4dec9608c75d78384c
4
+ data.tar.gz: cff39593ed8b01083d87c438617e3a8d073559db
5
5
  SHA512:
6
- metadata.gz: 368ca003b9182f912b7b81b3b4d5715d33c33cb047f16d3b6ae29a38a722e13494f60837e1aa05c7608a8628311aa585c2769407664557a735e14af4513430d8
7
- data.tar.gz: c99816b5ede4d23cf3442b00bf9eb7feadf26a0a3c811c63c65ca8e48ecd1997858a8cedfda6376c6de17882e986003f08b791610a9a48cd0b77b83ace70d077
6
+ metadata.gz: 8fa7c5702425a8494356236f444f10403a8f5bd21ae4029b3d3965c08e5f344830ab83dc05573b2ad32c29012820a215aac6383c26c8d61a542f33f6995311d7
7
+ data.tar.gz: c1f15938485dbe86c96abff5e0b922a4c270400f76d7202cc87e194e6513da934f9f5f467f6778edd960b982f8e22c4f0aa2c19427c3cfa48f4a4917eaeb9827
@@ -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**
@@ -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, :_subscribed_callaback, :_pinged_callback
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
- _websocket_client.onopen do
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._subscribed_callaback = block
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
- _subscribed_callaback&.call
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)
@@ -4,6 +4,7 @@ class ActionCableClient
4
4
  class Message
5
5
  IDENTIFIER_KEY = 'identifier'
6
6
  IDENTIFIER_PING = 'ping'
7
+ IDENTIFIER_WELCOME = 'welcome'
7
8
  # Type is never sent, but is received
8
9
  # TODO: find a better place for this constant
9
10
  TYPE_KEY = 'type'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ActionCableClient
4
- VERSION = '2.0.1'
4
+ VERSION = '2.0.2'
5
5
  end
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.1
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-09-11 00:00:00.000000000 Z
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.1
120
+ summary: ActionCableClient-2.0.2
121
121
  test_files: []