Skip to content

Commit

Permalink
Updated channel_manager,
Browse files Browse the repository at this point in the history
1. marked notify_state_change as accessible
2. annotated code with right spec ids
  • Loading branch information
sacOO7 committed Jul 4, 2024
1 parent d37be2f commit 07aadbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/ably/realtime/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def __incoming_msgbus__
# @return [Ably::Models::ChannelOptions]
def set_options(channel_options)
@options = Ably::Models::ChannelOptions(channel_options)

# RTL4i
manager.request_reattach if (need_reattach? and connection.state?(:connected))
end
alias options= set_options
Expand Down
14 changes: 8 additions & 6 deletions lib/ably/realtime/channel/channel_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(channel, connection)
def attach
if can_transition_to?(:attached)
connect_if_connection_initialized
send_attach_protocol_message if connection.state?(:connected)
send_attach_protocol_message if connection.state?(:connected) # RTL4i
end
end

Expand Down Expand Up @@ -167,6 +167,12 @@ def start_attach_from_suspended_timer
end
end

# RTL13c
def notify_state_change
@pending_state_change_timer.cancel if @pending_state_change_timer
@pending_state_change_timer = nil
end

private
attr_reader :pending_state_change_timer

Expand Down Expand Up @@ -210,6 +216,7 @@ def send_attach_protocol_message

state_at_time_of_request = channel.state
attach_action = Ably::Models::ProtocolMessage::ACTION.Attach
# RTL4f
@pending_state_change_timer = EventMachine::Timer.new(realtime_request_timeout) do
if channel.state == state_at_time_of_request
error = Ably::Models::ErrorInfo.new(code: Ably::Exceptions::Codes::CHANNEL_OPERATION_FAILED_NO_RESPONSE_FROM_SERVER, message: "Channel #{attach_action} operation failed (timed out)")
Expand Down Expand Up @@ -257,11 +264,6 @@ def send_detach_protocol_message(previous_state)
send_detach_message.call
end

def notify_state_change
@pending_state_change_timer.cancel if @pending_state_change_timer
@pending_state_change_timer = nil
end

def logger
connection.logger
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ably/realtime/channel/channel_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ChannelStateMachine
transition :from => :failed, :to => [:attaching, :initialized]

after_transition do |channel, transition|
channel.manager.notify_state_change
channel.manager.notify_state_change # RTL13c
channel.synchronize_state_with_statemachine
end

Expand Down

0 comments on commit 07aadbd

Please sign in to comment.