* Fix file transfer bug for WebSockets and SSH. Set/restore temp data handler belongs in base client.
* Lint some files
This commit is contained in:
parent
b2ae81c59e
commit
388e581b90
|
@ -100,6 +100,16 @@ function Client(/*input, output*/) {
|
|||
}
|
||||
});
|
||||
|
||||
this.setTemporaryDirectDataHandler = function(handler) {
|
||||
this.input.removeAllListeners('data');
|
||||
this.input.on('data', handler);
|
||||
};
|
||||
|
||||
this.restoreDataHandler = function() {
|
||||
this.input.removeAllListeners('data');
|
||||
this.input.on('data', this.dataHandler);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Peek at incoming |data| and emit events for any special
|
||||
|
|
|
@ -129,6 +129,10 @@ function SSHClient(clientConn) {
|
|||
}
|
||||
});
|
||||
|
||||
this.dataHandler = function(data) {
|
||||
self.emit('data', data);
|
||||
};
|
||||
|
||||
this.updateTermInfo = function(info) {
|
||||
//
|
||||
// From ssh2 docs:
|
||||
|
@ -191,9 +195,7 @@ function SSHClient(clientConn) {
|
|||
|
||||
self.setInputOutput(channel.stdin, channel.stdout);
|
||||
|
||||
channel.stdin.on('data', data => {
|
||||
self.emit('data', data);
|
||||
});
|
||||
channel.stdin.on('data', self.dataHandler);
|
||||
|
||||
if(self.cachedPtyInfo) {
|
||||
self.updateTermInfo(self.cachedPtyInfo);
|
||||
|
|
|
@ -486,16 +486,6 @@ function TelnetClient(input, output) {
|
|||
newEnvironRequested : false,
|
||||
};
|
||||
|
||||
this.setTemporaryDirectDataHandler = function(handler) {
|
||||
this.input.removeAllListeners('data');
|
||||
this.input.on('data', handler);
|
||||
};
|
||||
|
||||
this.restoreDataHandler = function() {
|
||||
this.input.removeAllListeners('data');
|
||||
this.input.on('data', this.dataHandler);
|
||||
};
|
||||
|
||||
this.dataHandler = function(b) {
|
||||
if(!Buffer.isBuffer(b)) {
|
||||
EnigAssert(false, `Cannot push non-buffer ${typeof b}`);
|
||||
|
|
|
@ -30,6 +30,10 @@ function WebSocketClient(ws, req, serverType) {
|
|||
|
||||
const self = this;
|
||||
|
||||
this.dataHandler = function(data) {
|
||||
self.socketBridge.emit('data', data);
|
||||
};
|
||||
|
||||
//
|
||||
// This bridge makes accessible various calls that client sub classes
|
||||
// want to access on I/O socket
|
||||
|
@ -65,9 +69,7 @@ function WebSocketClient(ws, req, serverType) {
|
|||
}
|
||||
}(ws);
|
||||
|
||||
ws.on('message', data => {
|
||||
this.socketBridge.emit('data', data);
|
||||
});
|
||||
ws.on('message', this.dataHandler);
|
||||
|
||||
ws.on('close', () => {
|
||||
// we'll remove client connection which will in turn end() via our SocketBridge above
|
||||
|
|
Loading…
Reference in New Issue