File tree Expand file tree Collapse file tree 2 files changed +9
-24
lines changed
Expand file tree Collapse file tree 2 files changed +9
-24
lines changed Original file line number Diff line number Diff line change @@ -283,22 +283,22 @@ def attach(&success_block)
283283 # @return [Ably::Util::SafeDeferrable] Deferrable that supports both success (callback) and failure (errback) callback
284284 #
285285 def detach ( &success_block )
286- if initialized?
286+ if initialized? || detached? # RTL5a
287287 success_block . call if block_given?
288288 return Ably ::Util ::SafeDeferrable . new_and_succeed_immediately ( logger )
289289 end
290290
291- if failed? || connection . closing? || connection . failed?
291+ if failed? || connection . closing? || connection . failed? # RTL5b, RTL5g
292292 return Ably ::Util ::SafeDeferrable . new_and_fail_immediately ( logger , exception_for_state_change_to ( :detaching ) )
293293 end
294294
295- if ! detached?
296- if attaching?
295+ connection . once_or_if :connected do # RTL5h
296+ if attaching? || detaching?
297297 # Let the pending operation complete (#RTL5i)
298298 once_state_changed { transition_state_machine :detaching if can_transition_to? ( :detaching ) }
299299 elsif can_transition_to? ( :detaching )
300300 transition_state_machine :detaching
301- else
301+ else # RTL5j
302302 transition_state_machine! :detached
303303 end
304304 end
Original file line number Diff line number Diff line change @@ -243,25 +243,10 @@ def send_detach_protocol_message(previous_state)
243243 end
244244 end
245245
246- on_disconnected_and_connected = lambda do
247- connection . unsafe_once ( :disconnected ) do
248- connection . unsafe_once ( :connected ) do
249- yield if pending_state_change_timer
250- end if pending_state_change_timer
251- end
252- end
253-
254- send_detach_message = lambda do
255- on_disconnected_and_connected . call do
256- send_detach_message . call
257- end
258- connection . send_protocol_message (
259- action : detach_action . to_i ,
260- channel : channel . name
261- )
262- end
263-
264- send_detach_message . call
246+ connection . send_protocol_message_immediately (
247+ action : detach_action . to_i ,
248+ channel : channel . name
249+ )
265250 end
266251
267252 def logger
You can’t perform that action at this time.
0 commit comments