creator3.x ts websocket 收到的消息被尾0截断

下面是skynet服务器代码
这里是打包发包包体 包括包头和protobuf的内容 head包头 content是protobuf内容
local function pack(head, content)
if(not content) then
head.msgSize = common.MSG_HEAD_SIZE
end
local package = string.pack("<I2", head.msgSize)
package = package … string.pack("<I2", head.mainID)
package = package … string.pack("<I2", head.assistantID)
if(content) then
package = package … content
end
return package
end

local data = pack(head, buf) --这里是打包代码
websocket.write(fd, data) --发送
以上是skynet服务器的代码,在cocos-lua使用websocket完全没问题,但是在creator3.x里 我在ts里使用websocket就出问题了,收到的包总是长度为1,发现是因为我打包第一个字段是包头小于256之后首部为0 感觉被截断了一样,这个问题怎么解决呢?疑惑的是在cocos-lua里面使用websocket完全没问题 不会被截断 根据使用例子 cocos-lua里使用的时候onmessage的参数直接是收包内容 而在creator里面onmessage的参数是event,需要event.data才是收包内容。