Fix writing packets by name or [state,id]

This commit is contained in:
roblabla 2015-05-22 22:24:47 +00:00
parent f5192ba8b7
commit 64f24858dd

View File

@ -173,6 +173,13 @@ function noop(err) {
}
Client.prototype.write = function(packetId, params, cb = noop) {
if(Array.isArray(packetId)) {
if(packetId[0] !== this.state)
return false;
packetId = packetId[1];
}
if(typeof packetId === "string")
packetId = protocol.packetIds[this.state][this.isServer ? "toClient" : "toServer"][packetId];
var packetName = protocol.packetNames[this.state][this.isServer ? "toClient" : "toServer"][packetId];
debug("writing packetId " + this.state + "." + packetName + " (0x" + packetId.toString(16) + ")");
debug(params);