mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-27 17:55:45 -05:00
Fix readRaw, writeRaw
This commit is contained in:
parent
a2b06f70a2
commit
e37a820709
1 changed files with 7 additions and 4 deletions
|
@ -93,10 +93,11 @@ Client.prototype.setSocket = function(socket) {
|
|||
//incomingBuffer = incomingBuffer.slice(parsed.size); TODO: Already removed in prepare
|
||||
|
||||
var packetName = protocol.packetNames[self.state][self.isServer ? 'toServer' : 'toClient'][packet.id];
|
||||
var packetState = self.state;
|
||||
self.emit(packetName, packet);
|
||||
self.emit('packet', packet);
|
||||
self.emit('raw.' + packetName, parsed.buffer);
|
||||
self.emit('raw', parsed.buffer);
|
||||
self.emit('raw.' + packetName, parsed.buffer, packetState);
|
||||
self.emit('raw', parsed.buffer, packetState);
|
||||
prepareParse();
|
||||
}
|
||||
|
||||
|
@ -214,9 +215,11 @@ Client.prototype.write = function(packetId, params) {
|
|||
Client.prototype.writeRaw = function(buffer) {
|
||||
var self = this;
|
||||
|
||||
var finishWriting = function(buffer) {
|
||||
var finishWriting = function(error, buffer) {
|
||||
if (error)
|
||||
throw error; // TODO : How do we handle this error ?
|
||||
var out = self.encryptionEnabled ? new Buffer(self.cipher.update(buffer), 'binary') : buffer;
|
||||
that.socket.write(out);
|
||||
self.socket.write(out);
|
||||
};
|
||||
if (this.compressionThreshold >= 0 && buffer.length >= this.compressionThreshold) {
|
||||
compressPacketBuffer(buffer, finishWriting);
|
||||
|
|
Loading…
Reference in a new issue