3.3.4 • Published 11 months ago

socket.io-parser v3.3.4

Weekly downloads
7,772,701
License
MIT
Repository
github
Last release
11 months ago

socket.io-parser

Build Status NPM version

A socket.io encoder and decoder written in JavaScript complying with version 3 of socket.io-protocol. Used by socket.io and socket.io-client.

Parser API

socket.io-parser is the reference implementation of socket.io-protocol. Read the full API here: socket.io-protocol.

Example Usage

Encoding and decoding a packet

var parser = require('socket.io-parser');
var encoder = new parser.Encoder();
var packet = {
  type: parser.EVENT,
  data: 'test-packet',
  id: 13
};
encoder.encode(packet, function(encodedPackets) {
  var decoder = new parser.Decoder();
  decoder.on('decoded', function(decodedPacket) {
    // decodedPacket.type == parser.EVENT
    // decodedPacket.data == 'test-packet'
    // decodedPacket.id == 13
  });

  for (var i = 0; i < encodedPackets.length; i++) {
    decoder.add(encodedPackets[i]);
  }
});

Encoding and decoding a packet with binary data

var parser = require('socket.io-parser');
var encoder = new parser.Encoder();
var packet = {
  type: parser.BINARY_EVENT,
  data: {i: new Buffer(1234), j: new Blob([new ArrayBuffer(2)])}
  id: 15
};
encoder.encode(packet, function(encodedPackets) {
  var decoder = new parser.Decoder();
  decoder.on('decoded', function(decodedPacket) {
    // decodedPacket.type == parser.BINARY_EVENT
    // Buffer.isBuffer(decodedPacket.data.i) == true
    // Buffer.isBuffer(decodedPacket.data.j) == true
    // decodedPacket.id == 15
  });

  for (var i = 0; i < encodedPackets.length; i++) {
    decoder.add(encodedPackets[i]);
  }
});

See the test suite for more examples of how socket.io-parser is used.

License

MIT

socket.io-clientsocket.io@arisageha/react-lazyload@arisageha/react-lazyload-fixeni-chat@tf2autobot/socket.io-clientlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29unblock-block-save-variablescclibyarntestopea-bootstraap@everything-registry/sub-chunk-2792ondwinx-form-winxweb-component-tester-bundlevw-socket.iowebdatabasetest1webdatabasetest10wxmp-socket.io-clientws-toolwxapp-socket.io-clientsuper-editertestweblibapitestlib17switch-socket.io-clientvcloudcam-playkit-js-hlsvideo-multi-uploadervue-dev-clone@ctfdio/picocss-themes@coremail/socket.io-client@caff/socket.iocauseway-concrete-stylesjeuxuiio-socket.ioka-flow.js3.0.0stock-ticker-react-widgettest-build-socket.iotest-build-socket.io-clienttoyakotna6-student-management-systemtogether-core-chatwasp-socket@applaud/socket.io@applaud/socket.io-client@andrewiski/socket.io@ahora/socket.io@akashic/akashic-cli-serve@ax333l1/socket-io-bun@cdevine49/react-numeric-input@ckeditor/ckeditor-cloud-services-collaboration@axmit/scythe-core@boundless-inc/mobiledoc-dom-renderer@depyronick/socket.io-client.ng10-fixwc-starterkitwebliblevi3understanding-typescript-coursevchat@ferdinandvonhagen/socket-io-aws-sqs-emitter@fluidframework/server-services-shared@ksen/egg-socket.io@lofcz/sweetalert2-neutral@ngxvoice/ngx-voicelistner@nodata/action@enounca/socket.io@enounca/socket.io-client@fabwcie/ckeditor5-preview@k4connect/socket.io@k4connect/socket.io-client@kcerb/socket.io-client@jonny/socket.io-client@hieuquang2212/form@holytiny/wxmp-socket.io-client@juicefunny/socket.io@indiebackend/client-sdk@inesfidalgo/forge@kingsds/socket.io-client@moony-engineering/messageclient@object-studio/react-native-web@parkcedar/leaflet@socket.io/redis-emitter@seculum/vue-dev-clonemx-socket.iomx-socket.io-clientmultiplatformlevimpd-parser-1mynancemp-socket.io-clientmiguelcostero-ng2-toastymyui5librarymobomyreuselibrarymyui5librarychenoswedev
3.3.4

11 months ago

3.4.3

2 years ago

4.2.3

2 years ago

4.2.4

2 years ago

4.2.2

2 years ago

3.4.2

3 years ago

3.3.3

3 years ago

4.0.5

3 years ago

4.2.1

3 years ago

4.2.0

3 years ago

4.1.2

3 years ago

4.1.0

4 years ago

4.1.1

4 years ago

4.0.4

4 years ago

3.3.2

4 years ago

4.0.3

4 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.1-rc3

5 years ago

4.0.1-rc2

5 years ago

4.0.1-rc1

5 years ago

3.3.1

5 years ago

4.0.0

5 years ago

3.4.1

5 years ago

3.4.0

6 years ago

3.3.0

7 years ago

3.2.0

7 years ago

3.1.3

7 years ago

3.1.2

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.3.2

8 years ago

2.3.1

9 years ago

2.3.0

9 years ago

2.2.6

10 years ago

2.2.5

10 years ago

2.2.4

10 years ago

2.2.3

10 years ago

2.2.2

11 years ago

2.2.1

11 years ago

2.2.0

11 years ago

2.1.5

11 years ago

2.1.4

11 years ago

2.1.3

11 years ago

2.1.2

11 years ago

2.1.1

11 years ago

2.1.0

11 years ago

2.0.0

11 years ago

1.1.2

11 years ago

1.1.1

11 years ago

1.1.0

11 years ago

1.0.2

12 years ago

1.0.1

13 years ago