Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix stream info was modify after send message #85

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/internal/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Stream {
streamId: this.streamInfo.streamId,
streamTransfer: msg,
action: 'transfer',
}, this.streamInfo.endpoint)
}, { ...this.streamInfo.endpoint })
}

/**
Expand All @@ -81,7 +81,7 @@ export class Stream {
streamId: this.streamInfo.streamId,
streamTransfer: null,
action: 'close',
}, this.streamInfo.endpoint)
}, {... this.streamInfo.endpoint })
}

/**
Expand Down Expand Up @@ -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 = () => { }
Expand All @@ -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()

Expand Down