mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 14:13:45 -04:00
Fix crash when trying to write to socket
This commit is contained in:
parent
52078273fe
commit
00241c4044
@ -155,13 +155,15 @@ Client.prototype.write = function(packetId, params) {
|
|||||||
packetId = packetId[1];
|
packetId = packetId[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
// TODO: Which comes first, encryption or compression?
|
// TODO: Which comes first, encryption or compression?
|
||||||
|
|
||||||
var finishWriting = function(buffer) {
|
var finishWriting = function(buffer) {
|
||||||
debug("writing packetId " + packetId + " (0x" + packetId.toString(16) + ")");
|
debug("writing packetId " + packetId + " (0x" + packetId.toString(16) + ")");
|
||||||
debug(params);
|
debug(params);
|
||||||
var out = this.encryptionEnabled ? new Buffer(this.cipher.update(buffer), 'binary') : buffer;
|
var out = this.encryptionEnabled ? new Buffer(this.cipher.update(buffer), 'binary') : buffer;
|
||||||
this.socket.write(out);
|
that.socket.write(out);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,9 +181,11 @@ Client.prototype.writeRaw = function(buffer, shouldEncrypt) {
|
|||||||
shouldEncrypt = true;
|
shouldEncrypt = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
|
||||||
var finishWriting = function(buffer) {
|
var finishWriting = function(buffer) {
|
||||||
var out = (shouldEncrypt && this.encryptionEnabled) ? new Buffer(this.cipher.update(buffer), 'binary') : buffer;
|
var out = (shouldEncrypt && this.encryptionEnabled) ? new Buffer(this.cipher.update(buffer), 'binary') : buffer;
|
||||||
this.socket.write(out);
|
that.socket.write(out);
|
||||||
};
|
};
|
||||||
|
|
||||||
if(this.compressionThreshold != -1 && buffer.length > this.compressionThreshold) {
|
if(this.compressionThreshold != -1 && buffer.length > this.compressionThreshold) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user