Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_reply(sock, id, type, data) {
debug('request finished', type);
try {
data = toJSON(data);
} catch (e) {
console.error('SocketServer exception:', e);
}
sock.write(bser.dumpToBuffer({
id,
type,
data,
}));
// Debounce the kill timer to make sure all the bytes are sent through
// the socket and the client has time to fully finish and disconnect.
this._dieEventually();
}
_reply(sock, id, type, data) {
debug('request finished', type);
data = toJSON(data);
sock.write(bser.dumpToBuffer({
id,
type,
data,
}));
// Debounce the kill timer to make sure all the bytes are sent through
// the socket and the client has time to fully finish and disconnect.
this._dieEventually();
this._jobs--;
}
Client.prototype.sendNextCommand = function() {
if (this.currentCommand) {
// There's a command pending response, don't send this new one yet
return;
}
this.currentCommand = this.commands.shift();
if (!this.currentCommand) {
// No further commands are queued
return;
}
this.socket.write(bser.dumpToBuffer(this.currentCommand.cmd));
}
_send(message) {
message.id = uid();
this._sock.write(bser.dumpToBuffer(message));
return new Promise((resolve, reject) => {
this._resolvers[message.id] = {resolve, reject};
});
}
_send(message) {
message.id = uid();
this._sock.write(bser.dumpToBuffer(message));
return new Promise((resolve, reject) => {
this._resolvers[message.id] = {resolve, reject};
});
}