Class: Async::Bus::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/async/bus/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(endpoint = nil) ⇒ Client

Returns a new instance of Client.



29
30
31
32
# File 'lib/async/bus/client.rb', line 29

def initialize(endpoint = nil)
	@endpoint = endpoint || Protocol.local_endpoint
	@queue = Async::Queue.new
end

Instance Method Details

#connectObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# 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