Split the session, gate optional parameters on the peer version, own the SMPP version in defs

This commit is contained in:
2026-08-26 22:41:28 +02:00
parent 1e5807f647
commit 6d842a8539
23 changed files with 1381 additions and 803 deletions
+32
View File
@@ -0,0 +1,32 @@
/** Caps how many requests are on the wire at once; anything past the limit waits its turn. */
export class SendWindow {
private readonly limit: number;
private readonly waiting: (() => void)[] = [];
private inFlight = 0;
constructor(limit: number) {
this.limit = limit;
}
acquire(): Promise<void> {
if (this.inFlight < this.limit) {
this.inFlight++;
return Promise.resolve();
}
return new Promise<void>(resolve => this.waiting.push(resolve));
}
release(): void {
const next = this.waiting.shift();
if (next) {
next();
return;
}
this.inFlight--;
}
}