method

listen

Importance_0
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: Listener
listen() public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File actioncable/lib/action_cable/subscription_adapter/postgresql.rb, line 87
          def listen
            @adapter.with_subscriptions_connection do |pg_conn|
              catch :shutdown do
                loop do
                  until @queue.empty?
                    action, channel, callback = @queue.pop(true)

                    case action
                    when :listen
                      pg_conn.exec("LISTEN #{pg_conn.escape_identifier channel}")
                      @event_loop.post(&callback) if callback
                    when :unlisten
                      pg_conn.exec("UNLISTEN #{pg_conn.escape_identifier channel}")
                    when :shutdown
                      throw :shutdown
                    end
                  end

                  pg_conn.wait_for_notify(1) do |chan, pid, message|
                    broadcast(chan, message)
                  end
                end
              end
            end
          end
Register or log in to add new notes.