start method
Start server
Implementation
Future<void> start({bool wait = false}) async {
if (_startIsolate != null || _stopIsolate != null) {
return;
}
_startIsolate = await Isolate.spawn((Map data) {
Pointer<Void> implementation =
Pointer<Void>.fromAddress(data["implementation"] as int);
DynamicLibrary library =
DynamicLibrary.open(data["libraryPath"] as String);
SendPort port = data["port"] as SendPort;
Pointer<Pointer<Void>> exception =
WebFrameworkException.createException();
StartWebFrameworkServerDart function = library.lookupFunction<
StartWebFrameworkServerC,
StartWebFrameworkServerDart>("startWebFrameworkServer");
function.call(implementation, true, nullptr, exception);
port.send(exception.address);
}, {
"implementation": _implementation.address,
"libraryPath": _handler.libraryPath,
"port": _startPort.sendPort
});
if (wait) {
Pointer<Pointer<Void>> exception =
Pointer<Pointer<Void>>.fromAddress(await _startPort.first as int);
_startIsolate?.kill(priority: Isolate.immediate);
_startIsolate = null;
WebFrameworkException.checkException(exception, _handler);
} else {
_startPort.first.then((address) {
Pointer<Pointer<Void>> exception =
Pointer<Pointer<Void>>.fromAddress(address as int);
_startIsolate?.kill(priority: Isolate.immediate);
_startIsolate = null;
WebFrameworkException.checkException(exception, _handler);
});
}
}