javascript - 如何使用 node.js 中的 ac 头文件解析 UDP 数据包
问题描述
我正在尝试连接从赛车模拟器读取 Telemtry 数据的服务器。
我一直在研究如何侦听 UDP 数据包,到目前为止,我已经成功地能够侦听客户端并接收数据包,然后记录 ArrayBuffer。
我遇到了这个 StackOvervflow 答案,它显示了如何解析它
但是,我想知道是否有任何其他方式可以自动解析 C++ 头文件,或者我是否必须自己清理数据
这是我的 express node.js 服务器的示例
server.on("message", (buffer, rinfo) =>{
console.log("received udp message")
console.log(buffer)
})
这是 c++ 头文件的示例
enum EUDPStreamerPacketHandlerType
{
eCarPhysics = 0,
eRaceDefinition = 1,
eParticipants = 2,
eTimings = 3,
eGameState = 4,
eWeatherState = 5, // not sent at the moment, information can be found in the game state packet
eVehicleNames = 6, //not sent at the moment
eTimeStats = 7,
eParticipantVehicleNames = 8
};
我想知道是否有人可以指出我正确的方向,我的谷歌搜索并没有变成太多,任何帮助将不胜感激
解决方案
这是python代码
您可以将其转换为所需的 javascript 代码。
推荐阅读
- haskell - 是否可以定义这样的 malloc 和 free 以使其数据由 GHC 运行时管理?
- mysql - 我应该将列一一添加到mysql db而不是在一个语句中吗
- r - 根据投票百分比同时移动所有几何条
- html - 显示:表头组在打印时无法在 chorme 中工作
- git - Git 日志 - 显示合并请求 ID
- python - Pandas 按多列分组并从非分组列中选择非空最后一个值
- azure - MS GRAPH API - 创建订阅 - 403 错误 - 调用者无权访问资源
- java - Spring Boot 2.3.x - 如何在自定义@RestController 中应用投影?
- javascript - 如何将数据传递给 ajax 以进行快速 api 调用
- r - 归一化数据的低方差过滤器