lib/ably/realtime/client/incoming_message_dispatcher.rb in ably-1.2.4 vs lib/ably/realtime/client/incoming_message_dispatcher.rb in ably-1.2.6

- old
+ new

@@ -41,23 +41,28 @@ unless protocol_message.kind_of?(Ably::Models::ProtocolMessage) raise ArgumentError, "Expected a ProtocolMessage. Received #{protocol_message}" end + # RTL15b + if protocol_message.has_channel_serial? && + ( + protocol_message.action == :message || + protocol_message.action == :presence || + protocol_message.action == :attached + ) + get_channel(protocol_message.channel).tap do |channel| + logger.info "Setting channel serial for channel #{channel.name}, " << + "Previous: #{channel.properties.channel_serial}, New: #{protocol_message.channel_serial}" + channel.properties.channel_serial = protocol_message.channel_serial + end + end + unless protocol_message.action.match_any?(:nack, :error) logger.debug { "#{protocol_message.action} received: #{protocol_message}" } end - if protocol_message.action.match_any?(:sync, :presence, :message) - if connection.serial && protocol_message.has_connection_serial? && protocol_message.connection_serial <= connection.serial - error_message = "Protocol error, duplicate message received for serial #{protocol_message.connection_serial}" - logger.error error_message - return - end - end - - update_connection_recovery_info protocol_message connection.set_connection_confirmed_alive case protocol_message.action when ACTION.Heartbeat when ACTION.Ack @@ -168,13 +173,9 @@ connection.manager.connected_update protocol_message else reason = Ably::Exceptions::IncompatibleClientId.new("Client ID '#{protocol_message.connection_details.client_id}' in CONNECTED update specified by the server is incompatible with the library's configured client ID '#{client.client_id}'") 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 def ack_pending_queue_for_message_serial(ack_protocol_message) drop_pending_queue_from_ack(ack_protocol_message) do |protocol_message| ack_messages protocol_message.messages