超级简单的 XMPP 服务器或关于简单自定义 Openfire 组件的建议
我需要一个服务器来发送和接收来自运行我正在编写的多人游戏的 Android 客户端的 XMPP 消息。我选择 XMPP 是因为我不想长时间轮询,而且套接字可能会成为蜂窝网络上的一个问题(运营商可能会阻止它们)。
我一直在研究 OpenFire 虽然它听起来很棒,但我不需要管理面板语音聊天、聊天室等。它看起来非常重量级,适合企业聊天解决方案,而我所需要的只是匹配玩家并将他们的动作传递给彼此,最后记录分数。是否有 OpenFire 的精简版本,以便我只需注册一个组件即可服务所有请求?关于与 openfire 的适配,我找不到添加自定义组件来执行类似任务的明确示例。
我需要的是一个库或现有的简单服务器,我可以运行它并将自定义消息侦听器注册到其中。我只需要能够满足任何传入的请求并做出适当的响应。我希望我不必编写线程管理,因为这个问题对于典型的聊天服务器来说很常见,但我确实需要编写代码来解释和响应发送的消息。
我希望这是有道理的,任何编写过这样一段服务器代码的人我都会喜欢一个例子。对于那些还没有尝试过但知道如何开始的人,也请参与进来!越详细越好。
预先感谢,
加夫
I need a server to send and recieve XMPP messages from Android clients running a multiplayer game I'm writing. I picked XMPP because I don't want to long poll and Sockets can be an issue over the cellular network (Carriers may block them).
I have been looking at OpenFire whilst it sounds amazing, I don't need an admin panel Voice Chat, Chat Rooms etc. it seems very heavyweight and geared towards a chat solution for businesses when all I need is to match players and pass their moves to each other recording a score at the end. Is there a stripped down version of OpenFire so I can just register one component which will service all requests? Regarding adaptation with openfire I can't find a clear example of adding a custom component to perform a similar task.
What I need is a library or existing simple server which I can run and register my custom message listener to. I just need to be able to service any requests coming in and respond appropriately. I'm hoping that I don't have to write the thread management as that issue is common to a typical chat server but I do need to write the code to interpret and respond to the messages sent.
I hope this makes sense, anyone who has written such a piece of server code I would love an example. For those of you that haven't tried it but have an idea how you would start please chip in too! The more detail the better.
Thanks in advance,
Gav
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用几乎任何 XMPP 服务器;我知道 Openfire 可以工作,或者我最近也使用过 Prosody 它非常轻量且易于安装(在Linux)。
您想要的是一个独立组件,它使用 XMPP组件协议。这就是游戏智能所在。
有关更多详细信息,请参阅我之前对一个非常相似的问题的回答:
XMPP C# 交互
另一个查找信息的好地方是 Jack Moffitt,他创建了 chesspark.com(由于被 chess.com 收购,所以不可用)——一个匹配国际象棋用户和使用 XMPP 控制游戏。
请参阅这篇博文作为开始:
http://metajack.im/2008/11/21/chesspark_design_details_part_1_why_xmpp/
You can use almost any XMPP server; I know that Openfire will work, or I've also recently used Prosody which is very lightweight and easy to install (on Linux).
What you want is a standalone component that communicates with your XMPP server (and thereby can reach your users) using the XMPP component protocol. That's where the game intelligence lies.
See my previous answer to a very similar question for more detail:
XMPP C# Interaction
Another great place to look for information is anything written by Jack Moffitt, who created chesspark.com (since purchased by chess.com so not available) — a site that matched chess users and controlled games using XMPP.
See this blog post as a start:
http://metajack.im/2008/11/21/chesspark_design_details_part_1_why_xmpp/
如果您想要一个快速、轻量级的 XMPP 服务器,请尝试 Prosody。然而,其他答案是正确的,因为您需要查看 PubSub首先,然后编写您自己的组件,然后将功能直接添加到服务器。
If you want a fast, lightweight XMPP server, try Prosody. The other answers are right, however, in that you'll want to look at PubSub first, then writing your own component, before adding functionality directly to the server.
如果 OpenFire(或其他 XMPP 服务器)支持 pubsub,您应该能够使用开箱即用的 OpenFire(或其他 XMPP 服务器)来完成此操作。不确定您的具体需求,但我认为 个人赛事协议 或它的超集 PubSub 应该能够处理您的用例。 OpenFire 确实支持这两种协议。
如果这些不支持您的用例,则 自定义插件非常容易编写。
至于重量级还是轻量级,除非你有一些特别小的运行服务器的环境,我怀疑这并不重要。您根本不会使用许多现有的功能。
我使用 XMPP pubsub 来让客户端相互交流操作,以便用户可以获得组中同事正在处理的工作的实时更新。
You should be able to accomplish this with OpenFire (or other XMPP servers) out of the box if they support pubsub. Not sure of the specifics of your needs, but I would think that Personal Eventing Protocol or its superset PubSub should be able to handle your use case. OpenFire does support both these protocols.
If these do not support your use case, then a custom plugin is pretty easy to write.
As for the heavyweight or lightweight, unless you have some specifically small environment for running the server, I doubt it will matter. You simply won't be using many of the features that exist.
I have used XMPP pubsub for clients to communicate actions to each other so users can get live updates of what coworkers in a group are working on.