Class: Async::Bus::Server
- Inherits:
-
Object
- Object
- Async::Bus::Server
- Defined in:
- lib/async/bus/server.rb
Instance Attribute Summary collapse
-
#connected ⇒ Object
readonly
Returns the value of attribute connected.
Instance Method Summary collapse
- #accept ⇒ Object
-
#initialize(endpoint = nil) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(endpoint = nil) ⇒ Server
Returns a new instance of Server.
29 30 31 32 33 34 |
# File 'lib/async/bus/server.rb', line 29 def initialize(endpoint = nil) @endpoint = endpoint || Protocol.local_endpoint @connected = {} @context = {} end |
Instance Attribute Details
#connected ⇒ Object (readonly)
Returns the value of attribute connected.
36 37 38 |
# File 'lib/async/bus/server.rb', line 36 def connected @connected end |
Instance Method Details
#accept ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/async/bus/server.rb', line 38 def accept @endpoint.accept do |peer| connection = Protocol::Connection.server(peer) @connected[peer] = connection yield connection connection.run ensure connection = @connected.delete(peer) connection&.close end end |