gpt4 book ai didi

c# - API开发: Advice for Unity to loopback http transfer process

转载 作者:太空宇宙 更新时间:2023-11-04 02:06:35 25 4
gpt4 key购买 nike

我目前正在开发一个可在多平台 Unity 游戏中使用的 API。我需要将数据从客户端传输到我的数据库服务器。

我的问题与客户端到服务器的通信有关。最好的沟通方式是什么?- 带字段- 使用一个原始数据传递 json 对象。

我正在使用loopback.io

目前,我正在使用 field 执行所有操作,因为我的 HTTP 插件在编码过程中使用我的字符串进行有线操作,但我无法使用 express.js 成功读取它。

我希望获得更多有关良好实践/继续进行的方法的建议

这是我的接收器函数之一,根据我的观点,它可以表达许多参数。

  ApiElement.createSimpleElement = function(IdGameData, PositionX, PositionY, PositionZ, RotationY, RotationZ, Layer,
Type, Gravity, Health, MoveSpeed, FireSpeed, cb) {
var data = FillElement(IdGameData, PositionX, PositionY, PositionZ, RotationY, RotationZ, Layer, Type, Gravity,
Health, MoveSpeed, FireSpeed);
// Create the element
ApiElement.create(data, function(err, ApiElementInstance) {
if (err) {
cb(err, null);
} else {
console.log(ApiElementInstance);
cb(null, ApiElementInstance);
}
});

};

最佳答案

我会为您想要表示的每个 JSON 主体创建一个模型。据我在 Loopback 文档中看到,您可以告诉应用程序公开自定义模型(例如,包含您在该函数中传递的所有参数的 json),这将使代码更清晰且更易于维护,特别是如果您要在许多路由中使用模型对象。希望这会有所帮助。

引用:https://loopback.io/doc/en/lb3/Exposing-models-over-REST.html

关于c# - API开发: Advice for Unity to loopback http transfer process,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44053556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com