Updated tunnel response and request
This commit is contained in:
parent
596b99a99a
commit
1b96f430e8
6
lib.js
6
lib.js
@ -7,14 +7,12 @@ class TunnelRequest extends stream.Readable {
|
||||
this._requestId = requestId;
|
||||
|
||||
const onRequestPipe = (requestId, data) => {
|
||||
console.log("Res pipe size", data.length);
|
||||
if (this._requestId === requestId) {
|
||||
this.push(data);
|
||||
}
|
||||
};
|
||||
|
||||
const onRequestPipes = (requestId, data) => {
|
||||
// console.log("Res pipes size", data.length)
|
||||
if (this._requestId === requestId) {
|
||||
data.forEach((chunk) => {
|
||||
this.push(chunk);
|
||||
@ -63,7 +61,6 @@ class TunnelResponse extends stream.Duplex {
|
||||
if (duplex) {
|
||||
// for websocket request: bidirection
|
||||
const onResponsePipe = (responseId, data) => {
|
||||
console.log("Res pipe: ", data.toString());
|
||||
if (this._responseId === responseId) {
|
||||
this.push(data);
|
||||
}
|
||||
@ -108,16 +105,13 @@ class TunnelResponse extends stream.Duplex {
|
||||
}
|
||||
|
||||
_write(chunk, encoding, callback) {
|
||||
console.log("Res Write Chunk: ", chunk.length, encoding);
|
||||
this._socket.emit("response-pipe", this._responseId, chunk);
|
||||
this._socket.io.engine.once("drain", () => {
|
||||
console.log("hello = ", "callback...")
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
_writev(chunks, callback) {
|
||||
console.log("Res Write Chunks: ", chunks.length);
|
||||
this._socket.emit("response-pipes", this._responseId, chunks);
|
||||
this._socket.io.engine.once("drain", () => {
|
||||
callback();
|
||||
|
Loading…
Reference in New Issue
Block a user