@khorsheed/dsh-room 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/lib/client.js +270 -270
- package/lib/index.js +24 -0
- package/lib/typert.host.js +21 -21
- package/lib/typert.remote-client.js +21 -21
- package/lib/types/dispatch.d.ts +10 -0
- package/lib/types/dispatch.js +21 -0
- package/lib/types/index.js +6 -0
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -2351,7 +2351,28 @@ var DispatchEngine = class {
|
|
|
2351
2351
|
* coordinator for plan work, else the dispatch's `replyTo`), at most once
|
|
2352
2352
|
* per delivery. Public so a removal can settle the waits it breaks.
|
|
2353
2353
|
*/
|
|
2354
|
+
/** Report-gate decisions per recipient, one at a time (see reportOutcome). */
|
|
2355
|
+
gateQueues = /* @__PURE__ */ new Map();
|
|
2356
|
+
/**
|
|
2357
|
+
* Gate one arrived report for the member waiting on it. Decisions for the
|
|
2358
|
+
* same recipient run one at a time: a decision-model judgement takes a
|
|
2359
|
+
* second or two, and a later report deciding meanwhile (the 「最后一个结果」
|
|
2360
|
+
* rule) would hand over its batch without the one still being judged —
|
|
2361
|
+
* which then got held behind a round that had already answered.
|
|
2362
|
+
*/
|
|
2354
2363
|
async reportOutcome(room, dispatchSeq, deliveryId, fromId, outcome, text) {
|
|
2364
|
+
const source = room.snapshotEvents().find((event) => event.seq === dispatchSeq);
|
|
2365
|
+
const key = `${room.id} ${source?.type === "room/dispatch" ? source.data.replyTo ?? "" : ""}`;
|
|
2366
|
+
const next = (this.gateQueues.get(key) ?? Promise.resolve()).catch(() => {}).then(() => this.gateReport(room, dispatchSeq, deliveryId, fromId, outcome, text));
|
|
2367
|
+
this.gateQueues.set(key, next);
|
|
2368
|
+
next.then(() => {
|
|
2369
|
+
if (this.gateQueues.get(key) === next) this.gateQueues.delete(key);
|
|
2370
|
+
}, () => {
|
|
2371
|
+
if (this.gateQueues.get(key) === next) this.gateQueues.delete(key);
|
|
2372
|
+
});
|
|
2373
|
+
return next;
|
|
2374
|
+
}
|
|
2375
|
+
async gateReport(room, dispatchSeq, deliveryId, fromId, outcome, text) {
|
|
2355
2376
|
const events = room.snapshotEvents();
|
|
2356
2377
|
const source = events.find((event) => event.seq === dispatchSeq);
|
|
2357
2378
|
if (source?.type !== "room/dispatch" || source.data.origin !== "coordinator" && source.data.origin !== "member" || source.data.replyTo === void 0) return;
|
|
@@ -4576,6 +4597,9 @@ let RoomService = (() => {
|
|
|
4576
4597
|
ok: false,
|
|
4577
4598
|
error: loaded.error
|
|
4578
4599
|
};
|
|
4600
|
+
if (this.ctx.sessions.get(request.sessionId) === void 0 && (loaded.state.deliveries ?? []).some((row) => row.status === "held")) this.ensureLive(request.sessionId).catch((error) => {
|
|
4601
|
+
this.ctx.logger.warn(`room: reviving held reports failed: ${String(error)}`);
|
|
4602
|
+
});
|
|
4579
4603
|
return {
|
|
4580
4604
|
ok: true,
|
|
4581
4605
|
value: {
|