avancement planning
This commit is contained in:
+6
-8
@@ -16,19 +16,17 @@ export class InMemoryTransport {
|
||||
return [clientTransport, serverTransport];
|
||||
}
|
||||
async start() {
|
||||
var _a;
|
||||
// Process any messages that were queued before start was called
|
||||
while (this._messageQueue.length > 0) {
|
||||
const queuedMessage = this._messageQueue.shift();
|
||||
(_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, queuedMessage.message, queuedMessage.extra);
|
||||
this.onmessage?.(queuedMessage.message, queuedMessage.extra);
|
||||
}
|
||||
}
|
||||
async close() {
|
||||
var _a;
|
||||
const other = this._otherTransport;
|
||||
this._otherTransport = undefined;
|
||||
await (other === null || other === void 0 ? void 0 : other.close());
|
||||
(_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
|
||||
await other?.close();
|
||||
this.onclose?.();
|
||||
}
|
||||
/**
|
||||
* Sends a message with optional auth info.
|
||||
@@ -36,13 +34,13 @@ export class InMemoryTransport {
|
||||
*/
|
||||
async send(message, options) {
|
||||
if (!this._otherTransport) {
|
||||
throw new Error("Not connected");
|
||||
throw new Error('Not connected');
|
||||
}
|
||||
if (this._otherTransport.onmessage) {
|
||||
this._otherTransport.onmessage(message, { authInfo: options === null || options === void 0 ? void 0 : options.authInfo });
|
||||
this._otherTransport.onmessage(message, { authInfo: options?.authInfo });
|
||||
}
|
||||
else {
|
||||
this._otherTransport._messageQueue.push({ message, extra: { authInfo: options === null || options === void 0 ? void 0 : options.authInfo } });
|
||||
this._otherTransport._messageQueue.push({ message, extra: { authInfo: options?.authInfo } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user