voip.io
TypeScript icon, indicating that this package has built-in type declarations

0.0.0-alpha.1 • Public • Published

client.io

构建Web端更稳定高效的实时通信解决方案。

Use

Use npm/yarn/pnpm

pnpm add client.io

Example

Use WebSocketBucket

import { WebSocketBucket } from 'client.io';
import { jsonStringify2Parse } from 'client.io';
WebSocketBucket.create({
  name: 'ACK_WEBSOCKET',
  url: 'wss://wss.github.com/test-ws'
  heartRate: 5000,
  heartbeat: (send) => {
    send(
      'HeartBeat-client-' + `${new Date().getSeconds()}`,
    );
  },
  receive: (event) => {
    if (event.data) {
      const data = jsonStringify2Parse(event.data);
      if (data.ack && data.msgId) {
        setTimeout(() => {
          WebSocketBucket.sendMessage(
            JSON.stringify({ module: 'ack', msgId: data.msgId }),
            'ACK_WEBSOCKET',
          );
        }, 0);
      }
    }
    return event;
  },
  send: (event) => {
    return event;
  },
});

WebSocketBucket.receiveMessage((msgEvent) => {
}, 'ACK_WEBSOCKET');
WebSocketBucket.sendMessage('Hello World!', 'ACK_WEBSOCKET');

Readme

Keywords

Package Sidebar

Install

npm i voip.io

Weekly Downloads

0

Version

0.0.0-alpha.1

License

MIT

Unpacked Size

37.4 kB

Total Files

18

Last publish

Collaborators

  • ztes