From 00557f663acd7a8762925dbf0eab10a0b9fa713a Mon Sep 17 00:00:00 2001 From: Arnout Kazemier Date: Sat, 15 Oct 2011 15:30:23 +0200 Subject: [PATCH] Added error and heartbeat decoding --- benchmarks/decode.bench.js | 8 ++++++++ benchmarks/encode.bench.js | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/benchmarks/decode.bench.js b/benchmarks/decode.bench.js index 6492f4c3b0..4855d805ef 100644 --- a/benchmarks/decode.bench.js +++ b/benchmarks/decode.bench.js @@ -25,6 +25,14 @@ suite.add('event+data', function () { parser.decodePacket('5:::{"name":"edwald","args":[{"a": "b"},2,"3"]}'); }); +suite.add('heartbeat', function () { + parser.decodePacket('2:::'); +}); + +suite.add('error', function () { + parser.decodePacket('7:::2+0'); +}); + var payload = parser.encodePayload([ parser.encodePacket({ type: 'message', data: '5', endpoint: '' }) , parser.encodePacket({ type: 'message', data: '53d', endpoint: '' }) diff --git a/benchmarks/encode.bench.js b/benchmarks/encode.bench.js index 52b3536e3b..5037702d31 100644 --- a/benchmarks/encode.bench.js +++ b/benchmarks/encode.bench.js @@ -45,6 +45,22 @@ suite.add('event+data', function () { }); }); +suite.add('heartbeat', function () { + parser.encodePacket({ + type: 'heartbeat' + , endpoint: '' + }) +}); + +suite.add('error', function () { + parser.encodePacket({ + type: 'error' + , reason: 'unauthorized' + , advice: 'reconnect' + , endpoint: '' + }) +}) + suite.add('payload', function () { parser.encodePayload([ parser.encodePacket({ type: 'message', data: '5', endpoint: '' })