使用 xmpp 进行点对点多人游戏
我对多人游戏还很陌生。我为了自己的乐趣做了一些,但没有什么深刻的。
不管怎样,我想制作一款非常跨平台的游戏。客户将在我发布游戏的设备(最有可能是计算机(通过闪存)、iPhone 和 Android)上连接到他们的 Facebook 帐户。我是一名预算有限的独立开发人员(实际上更像是没有预算)。所以,我想制作一个点对点连接的游戏。由于维护服务器的成本,我想避免使用客户端/服务器设置。我遇到的问题是无法通过互联网连接对等点,并且游戏不适合通过本地 WiFi 玩。
所以,我有一个想法。我可以使用 facebook 内置的 xmpp 聊天功能通过互联网发送游戏的多人通信吗?我以前有用于多人游戏的xmpp头。还有人有其他想法吗?我知道 xmpp 可以点对点连接,但是可以通过互联网以某种方式完成吗?我不希望用户必须弄乱路由器设置才能玩。
感谢您的帮助!
I'm fairly new to multiplayer games. I have made a few for my own fun, but nothing profound.
Anyway, I want to make a game that is very cross-platform. The clients would be connected with their facebook accounts on the devices I release the game for (most likely computers (via flash), iPhone, and android). I am a solo developer on a shoestring budget (actually more like no budget). So, I want to make the game with a peer-to-peer connection. I would like to avoid using a client/server setup because of the cost to maintain a server. The problem I am running into is there is no way to connect peers over the internet, and the game is not meant to be played over a local wifi.
So, I have an idea. Can I use facebook's built in xmpp chat to send the game's multiplayer communication over the internet? I have head of xmpp being used for multiplayer games before. Does anyone have any other ideas? I understand that xmpp can be connected peer-to-peer, but can it be done over the internet somehow. I don't want the users to have to mess with router settings to play.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
P2P系统的主要问题是NAT和防火墙。防火墙可以在本地打开,而 NAT 在 99% 的情况下不能。在 IPv6 世界中将不再有 NAT,因此 P2P 对所有人都是免费的。
现在您想使用 Facebook 的 XMPP API 进行 P2P 多人游戏。嗯...由于上述原因,Facebook 的 XMPP 实际上是客户端/服务器。 Facebook 的 API 所做的一切都是对应用程序隐藏传输层,这意味着您可以在消息实际通过 Facebook 服务器传输时向“另一个用户”发送消息。 Skype 是 P2P+服务器环境的另一个示例。如果两个用户站在 NAT 后面,它会自动使用代理服务器。
这与 FB 的 XMPP 基本相同,因此您可以使用它,除非您的 Facebook 用户会在聊天窗口中看到很多奇怪的消息:)
The main problem in P2P systems are NATs and firewalls. Firewalls can be locally opened, NATs cannot in 99% of the cases. In the IPv6 world there will be no NATs, so P2P will be free for all.
Now you want to use Facebook's XMPP APIs for P2P multiplayer. Well... Facebook's XMPP is practically client/server because of the above reason. All Facebook's APIs do is to hide the transport layer to applications, meaning that you can send messages to "another user" while they actually transit through Facebook server. Skype is another example of P2P+server environment. If two users stand behind a NAT, it automatically uses a proxy server.
This is mostly the same with FB's XMPP, so you can go with that, unless your facebook users will see lots of strange messages in their chat window :)
我认为你不能仅使用 facebook jabber 服务器来构建多人游戏。您需要在自己的服务器上安装一个自定义 jabber 组件,以在游戏用户之间传输的 xmpp 数据包上强制执行游戏业务逻辑。
这(可能)涉及编写自定义 Jabber 组件协议 XEP-0114 和 Bosh Connection Manager 组件位于您的末端。如果您希望使用 PHP 来开发应用程序,您可以查看 Jaxl 库 (XMPP PHP 中的组件和客户端库)
I think you cannot build a multi-player game just by using facebook jabber servers. You will need to have a custom jabber component sitting at your own server to enforce your game business logic on the xmpp packets transferred between the game users.
This will (probably) involve writing custom Jabber Component Protocol XEP-0114 and Bosh Connection Manager component at your end. If you are looking to use PHP for developing your application you can have a look at Jaxl library (XMPP component and client library in PHP)