From 64f24858dd003e276094e5a6d40dfec9a05c4365 Mon Sep 17 00:00:00 2001 From: roblabla Date: Fri, 22 May 2015 22:24:47 +0000 Subject: [PATCH] Fix writing packets by name or [state,id] --- src/client.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client.js b/src/client.js index f127918..9029325 100644 --- a/src/client.js +++ b/src/client.js @@ -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);