class Async::Bus::Client

Public Class Methods

new(endpoint = nil) click to toggle source
# File lib/async/bus/client.rb, line 29
def initialize(endpoint = nil)
        @endpoint = endpoint || Protocol.local_endpoint
        @queue = Async::Queue.new
end

Public Instance Methods

connect() { |connection| ... } click to toggle source
# File lib/async/bus/client.rb, line 34
def connect
        @endpoint.connect do |peer|
                connection = Protocol::Connection.client(peer)
                
                connection_task = Async do
                        connection.run
                end
                
                return yield(connection)
        ensure
                connection_task&.stop
        end
end

Protected Instance Methods

handle(connection, message) click to toggle source
# File lib/async/bus/client.rb, line 50
def handle(connection, message)
        # No default implementation.
end