lib/submodules/ably-ruby/lib/ably/models/presence_message.rb in ably-rest-1.1.6 vs lib/submodules/ably-ruby/lib/ably/models/presence_message.rb in ably-rest-1.1.7

- old
+ new

@@ -123,9 +123,23 @@ as_json(*args).tap do |presence_message| decode_binary_data_before_to_json presence_message end.to_json end + # The size is the sum over data and clientId in bytes (TO3l8a) + # + def size + %w(data client_id).map do |attr| + if (value = attributes[attr.to_sym]).is_a?(String) + value.bytesize + elsif value.nil? + 0 + else + value.to_json.bytesize + end + end.sum + end + # Assign this presence message to a ProtocolMessage before delivery to the Ably system # @api private def assign_to_protocol_message(protocol_message) @protocol_message = protocol_message end