From 8a6d4bc725f48ba971e49ef30a00ca6060720a65 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 7 Jan 2013 22:14:14 -0500 Subject: [PATCH] add ushort writer --- lib/protocol.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/protocol.js b/lib/protocol.js index 4684e1e..3cee6d1 100644 --- a/lib/protocol.js +++ b/lib/protocol.js @@ -450,6 +450,7 @@ var packets = { var writers = { 'int': IntWriter, 'short': ShortWriter, + 'ushort': UShortWriter, 'byte': ByteWriter, 'ubyte': UByteWriter, 'string': StringWriter, @@ -963,6 +964,15 @@ ShortWriter.prototype.write = function(buffer, offset) { buffer.writeInt16BE(this.value, offset); } +function UShortWriter(value) { + this.value = value; + this.size = 2; +} + +UShortWriter.prototype.write = function(buffer, offset) { + buffer.writeUInt16BE(this.value, offset); +} + function IntWriter(value) { this.value = value; this.size = 4;