@samlior/socket-io-client
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

@samlior/socket-io-client

@samlior/socket-io-client is a socketIO client based on JSONRPC.

Install

npm install @samlior/socket-io-client

Usage

import {
  SocketIOClientManager,
  ISocketIOHandler,
} from "@samlior/socket-io-client";

class MockClientEchoHandler implements ISocketIOHandler {
  async handle(params: any): Promise<string> {
    if (typeof params !== "string") {
      throw new Error("invalid params");
    }
    return "from client " + params;
  }
}

async function main() {
  const manager = new SocketIOClientManager();
  const client = await manager.connect("wss://aaa.bbb.ccc/namespace");
  console.log("response:", await client.req("method", "params"));
  client.close();
}

main().catch((err) => console.log("main, catch error:", err));

Readme

Keywords

none

Package Sidebar

Install

npm i @samlior/socket-io-client

Weekly Downloads

2

Version

2.0.1

License

GPL-3.0-or-later

Unpacked Size

26.2 kB

Total Files

14

Last publish

Collaborators

  • samlior_