mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-09-26 11:00:55 -04:00
skip restart if existing veilidcore instance is running
This commit is contained in:
parent
2344184620
commit
3640d32e02
1 changed files with 30 additions and 31 deletions
|
@ -46,42 +46,41 @@ class ProcessorRepository {
|
||||||
|
|
||||||
Stream<VeilidUpdate> updateStream;
|
Stream<VeilidUpdate> updateStream;
|
||||||
|
|
||||||
try {
|
if (await Veilid.instance.isShutdown()) {
|
||||||
log.debug('Starting VeilidCore');
|
log.debug('Starting VeilidCore');
|
||||||
updateStream = await Veilid.instance
|
updateStream = await Veilid.instance
|
||||||
.startupVeilidCore(await getVeilidConfig(kIsWeb, VeilidChatApp.name));
|
.startupVeilidCore(await getVeilidConfig(kIsWeb, VeilidChatApp.name));
|
||||||
} on VeilidAPIExceptionAlreadyInitialized catch (_) {
|
|
||||||
log.debug(
|
_updateSubscription = updateStream.listen((update) {
|
||||||
'VeilidCore is already started, shutting down and restarting...');
|
if (update is VeilidLog) {
|
||||||
|
processLog(update);
|
||||||
|
} else if (update is VeilidUpdateAttachment) {
|
||||||
|
processUpdateAttachment(update);
|
||||||
|
} else if (update is VeilidUpdateConfig) {
|
||||||
|
processUpdateConfig(update);
|
||||||
|
} else if (update is VeilidUpdateNetwork) {
|
||||||
|
processUpdateNetwork(update);
|
||||||
|
} else if (update is VeilidAppMessage) {
|
||||||
|
processAppMessage(update);
|
||||||
|
} else if (update is VeilidAppCall) {
|
||||||
|
log.info('AppCall: ${update.toJson()}');
|
||||||
|
} else if (update is VeilidUpdateValueChange) {
|
||||||
|
processUpdateValueChange(update);
|
||||||
|
} else {
|
||||||
|
log.trace('Update: ${update.toJson()}');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
startedUp = true;
|
startedUp = true;
|
||||||
await shutdown();
|
|
||||||
updateStream = await Veilid.instance
|
await Veilid.instance.attach();
|
||||||
.startupVeilidCore(await getVeilidConfig(kIsWeb, VeilidChatApp.name));
|
} else {
|
||||||
|
log.debug('VeilidCore is already started, skipping startup');
|
||||||
|
startedUp = true;
|
||||||
|
// TODO: Need a way to get the updateStream and add a listener after it's already started.
|
||||||
|
// Without this, the app starts up, but things that depend on update stream never get notified.
|
||||||
|
// Example being the attachment state always shows the detached icon.
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateSubscription = updateStream.listen((update) {
|
|
||||||
if (update is VeilidLog) {
|
|
||||||
processLog(update);
|
|
||||||
} else if (update is VeilidUpdateAttachment) {
|
|
||||||
processUpdateAttachment(update);
|
|
||||||
} else if (update is VeilidUpdateConfig) {
|
|
||||||
processUpdateConfig(update);
|
|
||||||
} else if (update is VeilidUpdateNetwork) {
|
|
||||||
processUpdateNetwork(update);
|
|
||||||
} else if (update is VeilidAppMessage) {
|
|
||||||
processAppMessage(update);
|
|
||||||
} else if (update is VeilidAppCall) {
|
|
||||||
log.info('AppCall: ${update.toJson()}');
|
|
||||||
} else if (update is VeilidUpdateValueChange) {
|
|
||||||
processUpdateValueChange(update);
|
|
||||||
} else {
|
|
||||||
log.trace('Update: ${update.toJson()}');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
startedUp = true;
|
|
||||||
|
|
||||||
await Veilid.instance.attach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> shutdown() async {
|
Future<void> shutdown() async {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue