服务器发送事件与libgdx

huangapple go评论67阅读模式
英文:

Server Sent Event With libgdx

问题

我正在使用LibGdx创建一个多人游戏。
这个游戏正在使用一个后端,使用Rest Api,因此我正在使用http请求。

我目前希望在我的应用程序中使用服务器发送事件(Server Side Events),但是Gdx.net似乎不兼容服务器发送事件(来自HTML5标准化)。

我知道LibGdx提供了一些通过TCP连接实现相同目标的方法,但我想避免使用那种方式。

另外,我不排斥在我的应用程序中添加第三方库(如果这个第三方库在Android上可用)。

英文:

I'm creating a multiplayer game with LibGdx.
This game is using a BackEnd using Rest Api and in consequences I'm using http request.

I'm currently looking to use Server Side Events in my application but Gdx.net doesn't seem to be compatible with Server Sent Event (from the HTML5 Standardisation)

I Know LibGdx provide some way for accomplish the same goal with TCP connection but I want to avoid that.

Also I'm not against adding third library in my application (if this third library work in Android).

答案1

得分: 0

最终我使用了第三方库。
我使用了okHttp和okHttp-sse。

okHttp是一个为Android设计的HTTP客户端,所以我认为它是libGdx的一个不错解决方案。

而且因为我不想再使用两个HTTP库,所以我不再使用libGdx.Net了。

其中一个优点是okHttp似乎更健壮。

英文:

Finally i've used a third party library.
I've used okHttp with okHttp-sse.

OkHttp is a http Client designed for android so I think it's a good solution for libGdx.

And because I don't want to use 2 http library i don't use libGdx.Net anymore.

One good point about this is that okHttp seems more robust

huangapple
  • 本文由 发表于 2020年10月24日 06:28:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/64508027.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定