cocos2d-js - 如何处理 cocos2d-js 中的 []byte 流?
问题描述
我的游戏是由 cocos2d-js 开发的。在这里我面临一个挑战,我们使用 tcp-socket 与后端通信。
套接字有它的流规则,即
[4]byte totalLength big endian
[4]byte headerLength big endian
[4]byte bodyLength big endian
[]header header stream, marshalled by json
[]body body stream, marshalled by json
好的,这里如何在 cocos-2d-js 中很好地对其进行编码/解码
function encode(header, body) {
return buf
}
function decode(buf) {
return header,body
}
解决方案
推荐阅读
- ruby-on-rails - 如何在亚马逊 S3 路径中通过 ffmpeg 创建电影截图
- python - 过滤报告中的日期
- schema - JSON-LD 模式与 Facebook 像素冲突
- spring - 如何在spring响应中解压缩gzip压缩的内容?
- c++ - 如何在 C++ 中获取正则表达式的底层字符串?
- c++ - 显示 ld 通过 -l 找到的库路径
- php - 远程连接的 Mysql PDO 访问被拒绝,但 Mysql CLI 有效
- android - 是 JsonRequest
一个好主意? - android - 如何从 Cloud Firestore 制作可读的时间戳?
- python - 用多个变量替换熊猫中的多个列