lib/ably/realtime/connection/connection_state_machine.rb in ably-0.7.0 vs lib/ably/realtime/connection/connection_state_machine.rb in ably-0.7.1

- old
+ new

@@ -38,10 +38,14 @@ after_transition(to: [:connecting], from: [:disconnected, :suspended]) do |connection| connection.manager.reconnect_transport end + after_transition(to: [:connected]) do |connection, current_transition| + connection.manager.connected_with_error current_transition.metadata if current_transition.metadata + end + after_transition(to: [:disconnected, :suspended], from: [:connecting]) do |connection, current_transition| connection.manager.respond_to_transport_disconnected_when_connecting current_transition end after_transition(to: [:disconnected], from: [:connected]) do |connection, current_transition| @@ -50,13 +54,12 @@ after_transition(to: [:disconnected, :suspended]) do |connection| connection.manager.destroy_transport # never reuse a transport if the connection has failed end - after_transition(to: [:failed]) do |connection, current_transition| - connection.logger.fatal "ConnectionStateMachine: Connection failed - #{current_transition.metadata}" - connection.manager.destroy_transport + before_transition(to: [:failed]) do |connection, current_transition| + connection.manager.fail current_transition.metadata end after_transition(to: [:closing], from: [:initialized, :disconnected, :suspended]) do |connection| connection.manager.force_close_connection end @@ -68,15 +71,12 @@ before_transition(to: [:closed], from: [:closing]) do |connection| connection.manager.destroy_transport end # Transitions responsible for updating connection#error_reason - before_transition(to: [:disconnected, :suspended, :failed]) do |connection, current_transition| - connection.set_failed_connection_error_reason current_transition.metadata - end - - before_transition(to: [:connected, :closed]) do |connection, current_transition| - connection.set_failed_connection_error_reason nil + before_transition(to: [:connected, :closed, :disconnected, :suspended, :failed]) do |connection, current_transition| + reason = current_transition.metadata if is_error_type?(current_transition.metadata) + connection.set_failed_connection_error_reason reason end private def connection object