lib/ably/realtime/client/incoming_message_dispatcher.rb in ably-0.8.5 vs lib/ably/realtime/client/incoming_message_dispatcher.rb in ably-0.8.6
- old
+ new
@@ -71,11 +71,11 @@
if connection.disconnected? || connection.closing? || connection.closed? || connection.failed?
logger.debug "Incoming CONNECTED ProtocolMessage discarded as connection has moved on and is in state: #{connection.state}"
elsif connection.connected?
logger.error "CONNECTED ProtocolMessage should not have been received when the connection is in the CONNECTED state"
else
- connection.transition_state_machine :connected, reason: protocol_message.error, protocol_message: protocol_message
+ process_connected_message protocol_message
end
when ACTION.Disconnect, ACTION.Disconnected
connection.transition_state_machine :disconnected, reason: protocol_message.error unless connection.disconnected?
@@ -137,9 +137,19 @@
end
end
def process_connection_error(protocol_message)
connection.manager.error_received_from_server protocol_message.error
+ end
+
+ def process_connected_message(protocol_message)
+ if client.auth.token_client_id_allowed?(protocol_message.connection_details.client_id)
+ client.auth.configure_client_id protocol_message.connection_details.client_id
+ connection.transition_state_machine :connected, reason: protocol_message.error, protocol_message: protocol_message
+ else
+ reason = Ably::Exceptions::IncompatibleClientId.new("Client ID '#{protocol_message.connection_details.client_id}' specified by the server is incompatible with the library's configured client ID '#{client.client_id}'", 400, 40012)
+ connection.transition_state_machine :failed, reason: reason, protocol_message: protocol_message
+ end
end
def update_connection_recovery_info(protocol_message)
connection.update_connection_serial protocol_message.connection_serial if protocol_message.has_connection_serial?
end