import {bind_sendPacketStream} from './_stream_send.jsy' import {bind_recvPacketStream} from './_stream_recv.jsy' export * from './_stream_send.jsy' export * from './_stream_recv.jsy' export function stream_common(hub) :: return @{} createStreamChannel(rstream, wstream, channel_id) :: let [send_packed, pw_closed] = bind_sendPacketStream(wstream) let [recv, channel] = hub.router.codec_channel @ this.p2p || hub.p2p, send_packed, this.codec || hub.stream_codec let pr_closed = bind_recvPacketStream(rstream, recv) if channel_id :: channel.channel_id = channel_id channel.close = @=> :: wstream.end() if wstream.unref :: wstream.unref() return true channel.when_closed = Promise.all @# pw_closed, pr_closed return channel