init method
Implementation
Future<void> init() async {
await close();
server = await HttpServer.bind('0.0.0.0', 0);
server!.listen((HttpRequest request) {
final String id = request.uri.path.substring(1);
if (_subs.containsKey(id)) {
_subs[id]!.deliver(request);
} else if (request.uri.path == '/_list') {
request.response
..writeln(_subs.keys.join('\n'))
..close();
} else if (request.uri.path == '/_state') {
var out = '';
for (String sid in _subs.keys) {
out += '$sid: ${_subs[sid]!._lastValue}\n';
}
request.response
..write(out)
..close();
} else {
request.response.statusCode = HttpStatus.notFound;
request.response.close();
}
}, onError: (e) {});
}