Class: ActionCable::SubscriptionAdapter::EnhancedPostgresql::Listener

Inherits:
PostgreSQL::Listener
  • Object
show all
Defined in:
lib/action_cable/subscription_adapter/enhanced_postgresql.rb

Instance Method Summary collapse

Instance Method Details

#invoke_callback(callback, message) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/action_cable/subscription_adapter/enhanced_postgresql.rb', line 115

def invoke_callback(callback, message)
  if message.start_with?(LARGE_PAYLOAD_PREFIX)
    encrypted_payload_id = message.delete_prefix(LARGE_PAYLOAD_PREFIX)
    payload_id = @adapter.payload_encryptor.decrypt_and_verify(encrypted_payload_id)

    @adapter.with_broadcast_connection do |pg_conn|
      result = pg_conn.exec_params(SELECT_LARGE_PAYLOAD_QUERY, [payload_id])
      message = result.first.fetch("payload")
    end
  end

  @event_loop.post { super }
end