Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

socket.io-msgpack-parser

socketio41kMIT3.0.2TypeScript support: included

socket.io parser based on msgpack

readme

socket.io-msgpack-parser

An alternative to the default socket.io-parser, encoding and decoding packets with msgpack.

With that parser, the browser build will be a bit heavier (an additional 7.5 KB minified, 3.0 KB gzipped), but each message will be smaller (sent as binary).

Please note that you MUST use the parser on both sides (server & client).

See also:

Compatibility table:

Parser version Socket.IO server version
2.x 1.x / 2.x
3.x 3.x / 4.x

Usage

const io = require('socket.io');
const ioc = require('socket.io-client');
const customParser = require('socket.io-msgpack-parser');

const server = io(PORT, {
  parser: customParser
});

const socket = ioc('ws://localhost:' + PORT, {
  parser: customParser
});

socket.on('connect', () => {
  socket.emit('hello');
});

Format

socket.emit('hello', 'you') will create the following packet:

{
  "type": 2,
  "nsp": "/",
  "data": ["hello", "you"]
}

which will be encoded by the parser as:

<Buffer 83 a4 74 79 70 65 02 a3 6e 73 70 a1 2f a4 64 61 74 61 92 a5 68 65 6c 6c 6f a3 79 6f 75>

More information about the exchange protocol can be found here.

changelog

History

2022

2020

2017

Release notes

3.0.2 (2022-11-14)

There is now a index.d.ts definition file included in the package.

3.0.1 (2020-10-27)

3.0.0 (2020-10-23)

Features

  • implement Socket.IO protocol v5 (#3) (2e72611)

2.2.1 (2020-09-28)

Bug Fixes

2.2.0 (2017-08-09)

This release includes notepack.io 2.1.0, which has a much smaller browser bundle.

2.1.0 (2017-05-29)

This release removes the transpilation step (babel).

2.0.0 (2017-05-08)

An ES5-compliant build is now produced.

1.0.3 (2017-05-04)

1.0.2 (2017-05-04)

1.0.1 (2017-04-28)

1.0.0 (2017-02-21)

Features