From 46e105e46fa2d0fd3992ce78def6f1e570e75c42 Mon Sep 17 00:00:00 2001 From: Pi Date: Sat, 20 Apr 2024 12:48:33 +0700 Subject: [PATCH] fix: fix stream info was modify after send message --- src/internal/stream.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/internal/stream.ts b/src/internal/stream.ts index 54cee9d..b18c3cc 100644 --- a/src/internal/stream.ts +++ b/src/internal/stream.ts @@ -62,7 +62,7 @@ export class Stream { streamId: this.streamInfo.streamId, streamTransfer: msg, action: 'transfer', - }, this.streamInfo.endpoint) + }, { ...this.streamInfo.endpoint }) } /** @@ -81,7 +81,7 @@ export class Stream { streamId: this.streamInfo.streamId, streamTransfer: null, action: 'close', - }, this.streamInfo.endpoint) + }, {... this.streamInfo.endpoint }) } /** @@ -124,8 +124,8 @@ export const createStreamWirings = (endpointRuntime: EndpointRuntime) => { const streamyEmitter = createNanoEvents() endpointRuntime.onMessage<{ channel: string; streamId: string }, string>('__crx_bridge_stream_open__', (message) => { + const { sender, data } = message return new Promise((resolve) => { - const { sender, data } = message const { channel } = data let watching = false let off = () => { } @@ -134,7 +134,7 @@ export const createStreamWirings = (endpointRuntime: EndpointRuntime) => { const callback = onOpenStreamCallbacks.get(channel) if (typeof callback === 'function') { - callback(new Stream(endpointRuntime, { ...data, endpoint: sender })) + callback(new Stream(endpointRuntime, { ...data, endpoint: { ...sender } })) if (watching) off()