微信小程序支持 protobuf 吗?
如果微信小程序支持 google protobuf 的话 有没有 demo 参考。
原来项目中一直在用google protobuf,如果能够支持将会节约大量时间。
如果微信小程序支持 google protobuf 的话 有没有 demo 参考。
原来项目中一直在用google protobuf,如果能够支持将会节约大量时间。
代码格式好像乱了,我这里也贴了一份 https://github.com/Zhang19910325/protoBufferForWechat/issues/1
https://github.com/Zhang19910325/protoBufferForWechat, 使用这个库,我在websocket上使用protobuff成功了
真机上还要手动转换下,判断不是模拟器,再封装一遍,微信那边有bug。。。
const message = Hello2Server.create(msg)
const encodedMessage = Hello2Server.encode(message).finish()
console.log(`hello:`, encodedMessage)
let newMsg = encodedMessage
if (sysInfo.platform !== 'devtools') {
newMsg = new Uint8Array([...encodedMessage]).buffer
}
console.log('newMsg:', newMsg)
wx.sendSocketMessage({
data: newMsg
})
目前小程序用protoBufferForWechat,服务器用google protobuf。小程序通过websocket发unit8Array给服务器可以解析,但服务器发给小程序的ArrayBuffer转成unit8Array后, 报解析错误,那位同学遇到过?有解决吗?