Implemented readable in caller mode
This commit is contained in:
parent
8571776337
commit
a93211894d
2 changed files with 13 additions and 5 deletions
|
|
@ -2,7 +2,14 @@ const fs = require('fs');
|
|||
const dest = fs.createWriteStream('./output');
|
||||
const { SRTReadStream } = require('../index.js');
|
||||
|
||||
const srt = new SRTReadStream('0.0.0.0', 1234);
|
||||
srt.listen(readStream => {
|
||||
readStream.pipe(dest);
|
||||
});
|
||||
if (process.argv[2] === "listener") {
|
||||
const srt = new SRTReadStream('0.0.0.0', 1234);
|
||||
srt.listen(readStream => {
|
||||
readStream.pipe(dest);
|
||||
});
|
||||
} else {
|
||||
const srt = new SRTReadStream('127.0.0.1', 1234);
|
||||
srt.connect(readStream => {
|
||||
readStream.pipe(dest);
|
||||
});
|
||||
}
|
||||
|
|
@ -33,7 +33,8 @@ class SRTReadStream extends Readable {
|
|||
}
|
||||
|
||||
connect(cb) {
|
||||
this.fd = this.srt.connect(this.socket, address, port);
|
||||
this.srt.connect(this.socket, this.address, this.port);
|
||||
this.fd = this.socket;
|
||||
if (this.fd) {
|
||||
cb(this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue