Commit c47d1682 authored by nanahira's avatar nanahira

no registry on replacing ocgcore

parent 29cd7800
Pipeline #43422 passed with stages
in 3 minutes and 53 seconds
import { Awaitable, MayBeArray, ProtoMiddlewareDispatcher } from 'nfkit'; import { Awaitable, MayBeArray, ProtoMiddlewareDispatcher } from 'nfkit';
import type { Subscription } from 'rxjs';
import { Context } from '../app'; import { Context } from '../app';
import BetterLock from 'better-lock'; import BetterLock from 'better-lock';
import { import {
...@@ -1167,6 +1168,10 @@ export class Room { ...@@ -1167,6 +1168,10 @@ export class Room {
} }
ocgcore?: OcgcoreWorker; ocgcore?: OcgcoreWorker;
private ocgcoreRegistrySubscriptions = new WeakMap<
OcgcoreWorker,
Subscription
>();
private registry: Record<string, string> = {}; private registry: Record<string, string> = {};
turnCount = 0; turnCount = 0;
turnIngamePos = 0; turnIngamePos = 0;
...@@ -1366,15 +1371,18 @@ export class Room { ...@@ -1366,15 +1371,18 @@ export class Room {
} }
this.sendChat(`Debug: ${msg.message}`, ChatColor.RED); this.sendChat(`Debug: ${msg.message}`, ChatColor.RED);
}); });
ocgcore.registry$.subscribe((registry) => { const registrySubscription = ocgcore.registry$.subscribe((registry) => {
this.logger.debug( this.logger.debug(
{ registry }, { registry },
'Received registry update from OCGCoreWorker', 'Received registry update from OCGCoreWorker',
); );
Object.assign(this.registry, registry); Object.assign(this.registry, registry);
}); });
this.ocgcoreRegistrySubscriptions.set(ocgcore, registrySubscription);
this.ocgcore = ocgcore; this.ocgcore = ocgcore;
if (oldOcgcore) { if (oldOcgcore) {
this.ocgcoreRegistrySubscriptions.get(oldOcgcore)?.unsubscribe();
this.ocgcoreRegistrySubscriptions.delete(oldOcgcore);
this.disposeOcgcore(oldOcgcore); this.disposeOcgcore(oldOcgcore);
} }
return true; return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment