Skip to content

Commit a0a6caf

Browse files
Server#run delegates to Server#connected!.
1 parent 35e3cf0 commit a0a6caf

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/async/bus/server.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,23 @@ def initialize(endpoint = nil, **options)
2020
@options = options
2121
end
2222

23+
# Called when a connection is established.
24+
# Override this method to perform setup when a connection is established.
25+
#
26+
# @parameter connection [Protocol::Connection] The established connection.
27+
protected def connected!(connection)
28+
# Do nothing by default.
29+
end
30+
2331
# Accept incoming connections.
2432
# @yields {|connection| ...} Block called with each new connection.
25-
def accept
33+
def accept(&block)
2634
@endpoint.accept do |peer|
2735
connection = Protocol::Connection.server(peer, **@options)
2836

29-
yield connection
37+
connected!(connection, &block)
38+
39+
yield connection if block_given?
3040

3141
connection.run
3242
ensure

releases.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Unreleased
44

55
- Add support for multi-hop proxying.
6+
- Fix proxying of throw/catch value.
7+
- `Client#run` now takes a block.
8+
- `Server#run` delegates to `Server#connected!`.
69

710
## v0.2.0
811

0 commit comments

Comments
 (0)