Skip to content

Commit 23490c0

Browse files
committed
Allow using custom channel
1 parent b46b81e commit 23490c0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/networker/networker/lib/src/server.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ abstract class NetworkerServer<T extends ConnectionInfo> extends NetworkerBase {
4040
}
4141

4242
@protected
43-
Channel addClientConnection(T info) {
44-
final id = _findAvailableChannel();
45-
if (id == kAnyChannel) return id;
46-
_connections[id] = info;
47-
_connectController.add((id, info));
43+
Channel addClientConnection(T info, [Channel? id]) {
44+
if (id != null) {
45+
closeConnection(id);
46+
}
47+
final current = id ?? _findAvailableChannel();
48+
if (current == kAnyChannel) return current;
49+
_connections[current] = info;
50+
_connectController.add((current, info));
4851
_changeController.add(clientConnections);
49-
return id;
52+
return current;
5053
}
5154

5255
@protected

0 commit comments

Comments
 (0)