Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -3299,8 +3299,6 @@ _(see [spec/unit/models/protocol_message_spec.rb](./spec/unit/models/protocol_me
* [retrieves attribute :channel_serial](./spec/shared/model_behaviour.rb#L15)
* #connection_id
* [retrieves attribute :connection_id](./spec/shared/model_behaviour.rb#L15)
* #connection_key
* [retrieves attribute :connection_key](./spec/shared/model_behaviour.rb#L15)
* #==
* [is true when attributes are the same](./spec/shared/model_behaviour.rb#L41)
* [is false when attributes are not the same](./spec/shared/model_behaviour.rb#L46)
Expand Down Expand Up @@ -3386,11 +3384,6 @@ _(see [spec/unit/models/protocol_message_spec.rb](./spec/unit/models/protocol_me
* [contains the attributes from the JSON auth details](./spec/unit/models/protocol_message_spec.rb#L358)
* without a JSON value
* [contains an empty AuthDetails object](./spec/unit/models/protocol_message_spec.rb#L366)
* #connection_key (#TR4e)
* existing only in #connection_details.connection_key
* [is returned](./spec/unit/models/protocol_message_spec.rb#L377)
* existing in both #connection_key and #connection_details.connection_key
* [returns #connection_details.connection_key as #connection_key will be deprecated > 0.8](./spec/unit/models/protocol_message_spec.rb#L385)

### Ably::Models::PushChannelSubscription
_(see [spec/unit/models/push_channel_subscription_spec.rb](./spec/unit/models/push_channel_subscription_spec.rb))_
Expand Down
8 changes: 0 additions & 8 deletions lib/ably/models/protocol_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ module Ably::Models
# @!attribute [r] channel_serial
# @return [String] Contains a serial number for a message on the current channel
# @!attribute [r] connection_id
# @return [String] Contains a string public identifier for the connection
# @!attribute [r] connection_key
# @return [String] Contains a string private connection key used to recover this connection
# @!attribute [r] connection_serial
# @return [Bignum] Contains a serial number for a message sent from the server to the client
Expand Down Expand Up @@ -98,12 +96,6 @@ def initialize(hash_object, options = {})
end
end

def connection_key
# connection_key in connection details takes precedence over connection_key on the ProtocolMessage
# connection_key in the ProtocolMessage will be deprecated in future protocol versions > 0.8
connection_details.connection_key || attributes[:connection_key]
end

def id!
raise RuntimeError, 'ProtocolMessage #id is nil' unless id
id
Expand Down
8 changes: 4 additions & 4 deletions lib/ably/realtime/connection/connection_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ def connected(protocol_message)
EventMachine.next_tick { connection.trigger_resumed }
resend_pending_message_ack_queue
else
logger.debug { "ConnectionManager: Connection was not resumed, old connection ID #{connection.id} has been updated with new connection ID #{protocol_message.connection_id} and key #{protocol_message.connection_key}" }
logger.debug { "ConnectionManager: Connection was not resumed, old connection ID #{connection.id} has been updated with new connection ID #{protocol_message.connection_id} and key #{protocol_message.connection_details.connection_key}" }
nack_messages_on_all_channels protocol_message.error
force_reattach_on_channels protocol_message.error
end
else
logger.debug { "ConnectionManager: New connection created with ID #{protocol_message.connection_id} and key #{protocol_message.connection_key}" }
logger.debug { "ConnectionManager: New connection created with ID #{protocol_message.connection_id} and key #{protocol_message.connection_details.connection_key}" }
end

reattach_suspended_channels protocol_message.error

connection.configure_new protocol_message.connection_id, protocol_message.connection_key, protocol_message.connection_serial
connection.configure_new protocol_message.connection_id, protocol_message.connection_details.connection_key, protocol_message.connection_serial
end

# When connection is CONNECTED and receives an update
Expand All @@ -139,7 +139,7 @@ def connected_update(protocol_message)
# Update the connection details and any associated defaults
connection.set_connection_details protocol_message.connection_details

connection.configure_new protocol_message.connection_id, protocol_message.connection_key, protocol_message.connection_serial
connection.configure_new protocol_message.connection_id, protocol_message.connection_details.connection_key, protocol_message.connection_serial

state_change = Ably::Models::ConnectionStateChange.new(
current: connection.state,
Expand Down
22 changes: 2 additions & 20 deletions spec/unit/models/protocol_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def new_protocol_message(options)
subject.new({ action: 1 }.merge(options))
end

# TR4n, TR4b, TR4c, TR4d, TR4e
# TR4n, TR4b, TR4c, TR4d
it_behaves_like 'a model',
with_simple_attributes: %w(id channel channel_serial connection_id connection_key),
with_simple_attributes: %w(id channel channel_serial connection_id),
base_model_options: { action: 1 } do

let(:model_args) { [] }
Expand Down Expand Up @@ -417,24 +417,6 @@ def new_protocol_message(options)
end
end
end

context '#connection_key (#TR4e)' do
context 'existing only in #connection_details.connection_key' do
let(:protocol_message) { new_protocol_message(connectionDetails: { connectionKey: 'key' }) }

it 'is returned' do
expect(protocol_message.connection_key).to eql('key')
end
end

context 'existing in both #connection_key and #connection_details.connection_key' do
let(:protocol_message) { new_protocol_message(connectionKey: 'deprecated', connectionDetails: { connectionKey: 'key' }) }

it 'returns #connection_details.connection_key as #connection_key will be deprecated > 0.8' do
expect(protocol_message.connection_key).to eql('key')
end
end
end
end

context '#to_json', :api_private do
Expand Down