1.0.25 • Published 2 years ago

wspb v1.0.25

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years 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

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.11

2 years ago

1.0.21

2 years ago

1.0.10

2 years ago

1.0.20

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago