From 38152017929ba5115a071777350c16f7c9d61918 Mon Sep 17 00:00:00 2001 From: roblabla Date: Sat, 23 May 2015 10:27:35 +0000 Subject: [PATCH 1/2] Remove ustring --- protocol/protocol.json | 8 ++++---- src/datatypes/utils.js | 11 ----------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/protocol/protocol.json b/protocol/protocol.json index d9ddc79..add3f1c 100644 --- a/protocol/protocol.json +++ b/protocol/protocol.json @@ -32,7 +32,7 @@ "fields": [ { "name": "response", - "type": "ustring" + "type": "string" } ] }, @@ -231,7 +231,7 @@ "fields": [ { "name": "message", - "type": "ustring" + "type": "string" }, { "name": "position", @@ -1741,7 +1741,7 @@ }, { "name": "value", - "type": "ustring" + "type": "string" }, { "name": "isSigned", @@ -1751,7 +1751,7 @@ "name": "signature", "type": "condition", "typeArgs": { - "type": "ustring", + "type": "string", "field": "isSigned", "values": [ true diff --git a/src/datatypes/utils.js b/src/datatypes/utils.js index 26438b2..4604e26 100644 --- a/src/datatypes/utils.js +++ b/src/datatypes/utils.js @@ -1,14 +1,11 @@ var assert = require('assert'); -var STRING_MAX_LENGTH = 240; -var SRV_STRING_MAX_LENGTH = 32767; var getField = require("../utils").getField; module.exports = { 'varint': [readVarInt, writeVarInt, sizeOfVarInt], 'bool': [readBool, writeBool, 1], 'string': [readString, writeString, sizeOfString], - 'ustring': [readString, writeString, sizeOfUString], // TODO : remove ustring 'buffer': [readBuffer, writeBuffer, sizeOfBuffer] }; @@ -81,7 +78,6 @@ function writeString(value, buffer, offset) { function sizeOfString(value) { var length = Buffer.byteLength(value, 'utf8'); - assert.ok(length < STRING_MAX_LENGTH, "string greater than max length"); return sizeOfVarInt(length) + length; } @@ -116,10 +112,3 @@ function writeBuffer(value, buffer, offset) { function sizeOfBuffer(value) { return value.length; } - - -function sizeOfUString(value) { - var length = Buffer.byteLength(value, 'utf8'); - assert.ok(length < SRV_STRING_MAX_LENGTH, "string greater than max length"); - return sizeOfVarInt(length) + length; -} From 7ecfec8c3b03d5063066bf5e18a57699f755b01b Mon Sep 17 00:00:00 2001 From: roblabla Date: Sat, 23 May 2015 10:28:31 +0000 Subject: [PATCH 2/2] Remove ustring test --- test/test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test.js b/test/test.js index 941cb7a..6ab8225 100644 --- a/test/test.js +++ b/test/test.js @@ -60,7 +60,6 @@ var values = { 'byte': -10, 'ubyte': 8, 'string': "hi hi this is my client string", - 'ustring': "hi hi this is my server string", 'buffer': new Buffer(8), 'array': function(typeArgs) { if(typeof values[typeArgs.type] === "undefined") {