10
votes

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

3
The server must be java only? Did you took AMQP in account ?clyfe

3 Answers

8
votes

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/

4
votes

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.

1
votes

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.