start method
Start the server
Implementation
@override
Future<bool> start() async {
if (_state == SessionHostState.running) {
return true;
}
if (_state == SessionHostState.disposed) {
// Terminal, and silent for the same reason as a refused connection:
// `dispose` already closed `serverEvents`.
return false;
}
try {
if (ownsTransport) {
await onStart();
}
_markRunning();
if (ownsTransport) {
await onStarted();
}
return true;
} on Exception catch (e) {
// Only exceptions: a failed bind is reported as an event, a programming
// error (a missing transport hook, say) must surface.
addServerEvent(
ServerEvent(
type: ServerEventType.error,
message: startFailureMessage(e),
),
);
return false;
}
}