Android P2P 多人游戏(使用 a)XMPP/Google talk b)JXTA Peerdroid c)其他方式)

发布于 2024-08-23 15:52:19 字数 451 浏览 16 评论 0原文

我是一名 Android 开发者,我制作了一些棋盘游戏。现在我想制作一些多人棋盘游戏。我不想创建和托管自己的 Web 服务,所以我考虑了 P2P。

我发现的第一件事是 XMPP 协议,但它不是真正的 P2P,但如果我可以使用现有的 google talk 服务,我就准备好了。在使用您现有的谷歌帐户时是否可以这样做,而不干扰您的谷歌谈话客户端的正常工作?

然后我听说了 JXTA,一个真正的 P2P 解决方案,它已经从 J2ME 移植到 Android (http:// code.google.com/p/peerdroid/)。

也许我在这里把事情搞得太复杂了(就像我有时做的那样),

我只是想知道为棋盘游戏做简单的 P2P 的最简单方法。

欢迎您提出各种意见!提前致谢

I am an android developer and I made some board games. Now i want to make some of my board games multiplayer. I don't want to create and host my own web service, so i thought about P2P.

The first thing i found was the XMPP protocol, however it's not real P2P, but if i can use the existing google talk service, i'm ready to go. Is this possible while using your existing google account without interfering with the normal working of your google talk client?

Then i heard about JXTA, a real P2P solution, and it's already ported from J2ME to Android (http://code.google.com/p/peerdroid/).

Maybe i am overcomplexing things here (as i do sometimes)

I just want to know the easiest way to do simple P2P for a boardgame.

All your opinions are welcome! Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

瑾夏年华 2024-08-30 15:52:19

克里斯托夫,你的问题得到答案了吗?我最近也在开发一个多人应用程序,尽管我选择托管服务器(最初)。不过,我现在正在重新考虑我的选择,但我正在使用的库完全支持点对点通信。底层协议构建在 Google Protobuf 之上。它本质上是一个构建在 Netty 之上的全双工 RPC 堆栈,可以使用 Protobuf。以下是 RPC protobuf 堆栈的 URL:http://code.google.com/p /protobuf-rpc-pro/

作者非常有帮助,我发现了一些错误,没什么大不了的。让这些库在我的 Android 手机上运行时我也遇到了很少的问题,但它们并不是非常“紧凑”。没有什么特别大的,只是不小:)。到目前为止,我在同步和异步通信方面没有遇到任何问题。因此,我可能会将我的游戏转移到“点对点”风格,并仅提供用于查找现有游戏/服务器的必要位置/注册服务器。

Kristof, Did you get an answer to your question? I've been working on a multi-player application recently as well, though I've chosen to host the server (originally). I'm now reconsidering my choice, though, but the library I'm using fully supports peer to peer communications. The underlying protocol is built on top of Google Protobuf. It's essentially a full duplex RPC stack built on top of Netty, which can use Protobuf. Here's the URL to the RPC protobuf stack: http://code.google.com/p/protobuf-rpc-pro/

The author has been very helpful and I've found a couple of bugs, nothing major. I also had very little issues getting these libraries working on my Android phone, but they're not terribly "compact." Nothing extraordinarily large, just not small :). So far, I've had no issues getting the communications working both synchronously and asynchronously. As such, I may be moving my game over to a "peer to peer" style, and just provide the necessary location/registration server that would be used to find existing games/server.

—━☆沉默づ 2024-08-30 15:52:19

对于您的情况,使用 XMMP 应该是可能的。查看来自 igniterealtime 的 smack。他们有一个漂亮且活跃的 java api,可以帮助您构建自己的 jabber 扩展数据包,可用于传输游戏状态的变化。

我认为使用同一个帐户同时使用两个 google talk 客户端可能会很困难。但这会很棒,因为您可以直接从游戏中邀请列表中的所有朋友与您一起玩。这样您就可以轻松吸引更多人来玩您的游戏。

Using XMMP should be possible for you case. Look at smack from igniterealtime. They have a nice and active java api that helps to build you own jabber extension packets that can be used to transport the changes in game state.

I think that using two google talk clients at the same time with the same account could be difficult. But it would be great because you could invite all the friends from you list to play with you directly from your game. This way you could easily get more people to play your game.

情归归情 2024-08-30 15:52:19

据我们所知,您无法使用现有的 Google Talk 服务/连接。你应该听取 Janusz 的建议并查看 smack 库,这是你最好的选择。要允许使用同一 GTalk 登录进行多个互不干扰的连接,请查看 XMPP 地址的资源组件,它允许您同时登录到同一帐户的两个客户端。您可以有效地将您的游戏变成另一个客户端。更多详情请参见:http://code.google.com/appengine /docs/java/xmpp/overview.html#JIDs_and_Resources

最后,2.2 中似乎有一些与设备推送通信相关的新功能,但我还没有研究过。 2.2 也尚未广泛部署,因此用途可能有限。

You can't use the existing Google Talk Service/Connection from what we've seen. You should take Janusz's advice and check out the smack library, that's your best bet. To allow multiple non-interfering connections with the same GTalk login take a look at the resource component of the XMPP address, it's what allows you to be logged into two clients at the same time to the same account. You can effectively make your game another client. More here: http://code.google.com/appengine/docs/java/xmpp/overview.html#JIDs_and_Resources

Finally, there appears to be some new functionality in 2.2 relating to device push communication, but I haven't looked into it yet. 2.2 is not widely deployed yet either, so probably of limited use.

GRAY°灰色天空 2024-08-30 15:52:19

基本上,如果您想编写多用户游戏或基于 XMPP (Jabber) 构建的游戏,您应该认真研究 XMPP 的 pubsub 扩展。它旨在以与 HTTP 相反的方式将数据从服务器推送到客户端。在 HTTP 中,客户端必须始终从服务器提取信息,以便能够知道何时推送一些新数据。虽然 XMPP 的设计目的是在发生某些情况时将数据推送到客户端。服务器和客户端上使用的资源更少。

您不应该使用 XMPP 的聊天部分,因为这会干扰用户的存在。

在 pubsub 中,您可以创建一棵节点树,客户端可以在其中监听客户端订阅的树中任何节点或子节点中发布的任何新数据。因此,如果某个客户端在一个节点上发布数据,则订阅该节点的所有客户端或任何父节点都将收到有关此数据的通知。

XMPP 的优点在于它是可扩展的,因此您可以使用自己的扩展来扩展协议。我还给你用户授权、认证和加密,你不需要自己调试。

您可以使用任何对 pubsub 有良好支持的 XMPP 服务器,也可以自己托管一台服务器。有很多服务器可用于此。我上次查看时,GTalk 不支持 PubSub。

Basicly, if you want to write a multi user game or a game built on top of XMPP (Jabber), you should have a serious look at pubsub extension of XMPP. It's designed for pushing data from a server to clients, in the opposite way of HTTP. In HTTP the client has to pull information from the server all the time to be able to know when some new data is pushed. While XMPP is designed to push data to clients, when something happens. Less resources used on server and clients.

You should not use the Chat part of XMPP, as that will interfere with the users presence.

In pubsub you can create a tree of nodes, where clients can listen to any new data published in any node or subnod in the tree that the client subscribes to. So if some client publish data on one node, all clients that has subscribed to that node, or any parent, will be notified about this data.

The good part with XMPP is that it's extensible so you can extend the protocol with your own extensions. I also give you user authorization, authentification and encryption, and you don't need to debug that yourself.

You could use any XMPP-server with good support for pubsub or you can host one server yourself. There are plenty of servers usable for this. GTalk doesn't have support for PubSub last time I looked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文