|
|
@ -1,5 +1,6 @@
|
|
|
|
const WebSocketStream = require('websocket-stream')
|
|
|
|
const WebSocketStream = require('websocket-stream')
|
|
|
|
const ConcatStream = require('concat-stream')
|
|
|
|
const ConcatStream = require('concat-stream')
|
|
|
|
|
|
|
|
const CombinedStream = require('combined-stream')
|
|
|
|
const { Duplex, Readable } = require('stream')
|
|
|
|
const { Duplex, Readable } = require('stream')
|
|
|
|
const { Buffer } = require('buffer')
|
|
|
|
const { Buffer } = require('buffer')
|
|
|
|
|
|
|
|
|
|
|
@ -12,25 +13,14 @@ class Streamer {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
write(buffer) {
|
|
|
|
write(buffer) {
|
|
|
|
console.log('write buffer pre slice', buffer)
|
|
|
|
|
|
|
|
// buffer = buffer.slice(this.position, this.position + this.length)
|
|
|
|
|
|
|
|
// console.log('write buffer post slice', buffer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const write_stream = WebSocketStream(`ws://localhost:5746/?socket_uuid=${this.socket_uuid}&node_uuid=${this.node_uuid}&length=${this.length}&position=${this.position}&writing_file=true`, {
|
|
|
|
const write_stream = WebSocketStream(`ws://localhost:5746/?socket_uuid=${this.socket_uuid}&node_uuid=${this.node_uuid}&length=${this.length}&position=${this.position}&writing_file=true`, {
|
|
|
|
perMessageDeflate: false,
|
|
|
|
perMessageDeflate: false,
|
|
|
|
binary: true,
|
|
|
|
binary: true,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
console.log(write_stream)
|
|
|
|
const combined_stream = CombinedStream.create()
|
|
|
|
console.log('writing buffer', buffer.toString(), buffer)
|
|
|
|
combined_stream.append(buffer.toString('base64'))
|
|
|
|
|
|
|
|
combined_stream.pipe(write_stream)
|
|
|
|
write_stream.push(buffer)
|
|
|
|
|
|
|
|
write_stream.push(null)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const read_stream = new Readable()
|
|
|
|
|
|
|
|
// read_stream.push(buffer, 'utf8')
|
|
|
|
|
|
|
|
// read_stream.push(null)
|
|
|
|
|
|
|
|
// read_stream.pipe(write_stream)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
stream() {
|
|
|
|
stream() {
|
|
|
|