1.0.25 • Published 6 months ago

wspb v1.0.25

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

protobuf兼容

protobufjs https://protobufjs.github.io/protobuf.js/ buffer https://github.com/feross/buffer pako https://github.com/nodeca/pako#readme

安装 npm i wspb

使用

服务端: const {ProtoManager} = require('wspb') let pb = new ProtoManager() pb.initialzie('google proto file text',{coder:'pb'})

// package let bytes = pb.package('prototypename',{...});

// unpackage try{ let data = pb.unpackage(bytes) }catch(e){ console.error('unpackage error',e) }

客户端

const {ProtoManager} = require('wspb')

方法一,使用协议解码或者编码消息 let pb = new ProtoManager() pb.initialzie('',{coder:'ipb'})

// 打包消息 let bytes = pb.package('prototypename',{...});

// 解包消息 try{ let data = pb.unpackage(bytes) }catch(e){ console.error('unpackage error',e) }

方法二、使用socket

const {Socket} = require('wspb'); let c = new Socket(); c.on('prototypename',(name,data)=>{ }); c.connect('ws://xxxxx'); c.send('prototypename',data);

1.0.22

7 months ago

1.0.25

6 months ago

1.0.24

6 months ago

1.0.23

7 months ago

1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.11

7 months ago

1.0.21

7 months ago

1.0.10

7 months ago

1.0.20

7 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago