registerExtension method Null safety
- String extension,
- VmServerConnection client
Registers extension
for client
.
All future requests for extension
will be routed to client
.
Implementation
void registerExtension(String extension, VmServerConnection client) {
if (_extensionToConnection.containsKey(extension)) {
throw RPCError('registerExtension', 111, 'Service already registered');
}
_eventController.sink.add(_toRegistrationEvent(extension));
_extensionToConnection[extension] = client;
// Remove the mapping if the client disconnects.
client.done.whenComplete(() {
_extensionToConnection.remove(extension);
_eventController.sink.add(_toRegistrationEvent(extension,
kind: EventKind.kServiceUnregistered));
});
}