Class: Async::Bus::Server
- Inherits:
-
Object
- Object
- Async::Bus::Server
- Defined in:
- lib/async/bus/server.rb
Overview
Represents a server that accepts async-bus connections.
Instance Method Summary collapse
-
#accept(&block) ⇒ Object
Accept incoming connections.
-
#initialize(endpoint = nil, **options) ⇒ Server
constructor
Initialize a new server.
Constructor Details
#initialize(endpoint = nil, **options) ⇒ Server
Initialize a new server.
18 19 20 21 |
# File 'lib/async/bus/server.rb', line 18 def initialize(endpoint = nil, **) @endpoint = endpoint || Protocol.local_endpoint = end |
Instance Method Details
#accept(&block) ⇒ Object
Accept incoming connections.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/async/bus/server.rb', line 33 def accept(&block) @endpoint.accept do |peer| connection = Protocol::Connection.server(peer, **) connected!(connection, &block) yield connection if block_given? connection.run ensure connection&.close end end |