1.1.7 • Published 4 years ago

jsonrpc2websocket v1.1.7

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

jsonrpc2websocket

基于WebSocket+JSONRPC+msgpack+TypeScript封装的实时通讯函数

安装

$ npm install jsonrpc2websocket
# or
yarn add jsonrpc2websocket

使用

import Socket, { SocketType } from 'jsonrpc2websocket';

const socket: SocketType = new Socket({ url: 'ws://url' });

// 普通模式
socket.send({
    method: 'msg',
    callback: e => {
      console.log(e);
    },
});

// 流模式
const stream = socket.stream({
    method: 'start',
    callback: e => {
      console.log(e);
    },
});
stream.close();

// 接收所有消息
const socket: SocketType = new Socket({
  url: 'ws://url',
  onmessage: (res: Object) => console.log(res),
});
1.1.7

4 years ago

1.1.6

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago