{"library":"socket.io-msgpack-parser","title":"Socket.IO MessagePack Parser","type":"library","description":"This package offers an alternative parser for Socket.IO, utilizing the MessagePack format for efficient binary serialization of data instead of the default JSON-based parser. Its primary goal is to minimize message sizes, which is particularly advantageous for applications with high message throughput, though it results in a slightly larger browser bundle (an additional 7.5 KB minified, 3.0 KB gzipped). The current stable version is 3.0.2, which includes TypeScript definitions. The project maintains close compatibility with Socket.IO's protocol versions, requiring a matching parser version on both the server and client (e.g., parser 3.x with Socket.IO 3.x/4.x). This parser differentiates itself by providing a binary-optimized transport layer, a key contrast to the standard `socket.io-parser` and `socket.io-json-parser`.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install socket.io-msgpack-parser"],"cli":null},"imports":["import customParser from 'socket.io-msgpack-parser';","const customParser = require('socket.io-msgpack-parser');","import type { Parser } from 'socket.io-msgpack-parser';"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/socketio/socket.io-msgpack-parser","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/socket.io-msgpack-parser","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"const io = require('socket.io');\nconst ioc = require('socket.io-client');\nconst customParser = require('socket.io-msgpack-parser');\n\nconst PORT = process.env.PORT || 3000;\n\nconst server = io(PORT, {\n  parser: customParser\n});\n\nserver.on('connection', (socket) => {\n  console.log('Server: Client connected');\n  socket.on('hello', () => {\n    console.log('Server: Received hello from client');\n    socket.emit('world', 'from server');\n  });\n});\n\nconst socket = ioc('ws://localhost:' + PORT, {\n  parser: customParser\n});\n\nsocket.on('connect', () => {\n  console.log('Client: Connected');\n  socket.emit('hello');\n});\n\nsocket.on('world', (data) => {\n  console.log('Client: Received world:', data);\n  socket.disconnect();\n  server.close();\n});\n\nsocket.on('disconnect', () => {\n  console.log('Client: Disconnected');\n});\n\nconsole.log(`Server and client running on port ${PORT}`);","lang":"javascript","description":"Demonstrates how to integrate the MessagePack parser on both the Socket.IO server and client, ensuring consistent message encoding/decoding.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}