Skip to content

Commit

Permalink
Added error and heartbeat decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
3rd-Eden committed Oct 15, 2011
1 parent 54c22ae commit 00557f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions benchmarks/decode.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '' })
Expand Down
16 changes: 16 additions & 0 deletions benchmarks/encode.bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '' })
Expand Down

0 comments on commit 00557f6

Please sign in to comment.