An improved Pomelo JavaScript client supporting both browser and Node.js environments, with multi-client instance support, reconnection, wss protocol, and custom events for unified handling of server push and response messages. Version 1.0.13 is the latest stable release. Key differentiators from the official client include the ability to create multiple independent Pomelo client instances, support for the 'wss' scheme, reconnection features (since 1.0.5), and special events '__CLIENT_ROUTE' and '__CLIENT_RESPONSE' allowing centralized handling of all server messages. It also handles characters above U+FFFF. The package is published on npm but rarely updated, with no recent releases.
npm install pomelo-client-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating two Pomelo client instances, connecting to a gate server and then a connector server with wss and reconnection, and using custom events.
Use 'new Pomelo()' for each connection to avoid state conflicts.
Listen on 'connect' only if using this library; otherwise use the callback in init().
Use 'const Pomelo = require('pomelo-client-websocket/core');' for browser builds.Use 'require()' or ensure bundler handles CJS.
Ensure server also handles UTF-16 surrogate pairs correctly.
If using a bundler (webpack), ensure alias or use the main entry; for direct browser use, include the core script via <script> tag (not via require).
Use 'const Pomelo = require('pomelo-client-websocket');'For Node: install 'ws' (though it should be included). For browser: use the core entry or ensure WebSocket global exists.
Use 'pomelo-client-websocket/core' instead.