xmpp for turn based game

Started by
4 comments, last by All8Up 10 years, 4 months ago

Hey,

I am currently thinking about a network/server solution for a turn based game. I think turn based games have a lot in common with chat applications.

So one could use a chat server, and introduce (next to the normal chat messages for ingame chat) specially formatted messages, that represents moves.

Nice, that way I could use an existing xmpp server solution, which has a lot of benefits.

But I want some features which do not exist in a chat server:

* Using existing accounts (facebook, google+) for login, as well as creating new accounts.

* Testing player moves for validity.

* Storing a game in a cloud, so that the players can return to it later.

* Sending a push notification to a player on a mobile device when that player is currently not in the game but the opponent made a turn.

I could probably archive this, buy having a chat-bot for every game currently player over which the communication for that game works.

So if a player made a move, it sends a message to the bot. The bot validates it, updates the game state in the cloud and forwards the move to all other players.

So I am asking for your experience:

Do you think that is a good Idea?

Maybe there are chat servers out there which can be extended to make what I want in some other (better) way?

Or would you approach this completely different?

Thanks!

Advertisement

XMPP has a lot of good things to sell it for this. The basic concept of using it for games is already proven, ChessPark is a pretty reasonable example of online chess which can be played very fast (near realtime speed chess) or long term days on end chess. It all runs through XMPP using ejabberd and a couple custom erlang modules and XEP's. Additionally, with the bosh standard, you can route XMPP through a standard web server and use HTML 5 + java script + strophe js as your primary platform. At the minimum, your push notifications can be a simple web page the user can connect to and see turn status in realtime without having to refresh. Of course add in jquery/jquery ui and you can probably write the entire thing with the browser and it will just work on mobile as well as desktop.

Other examples of unusual uses of XMPP to consider in terms of just how flexible it is: last I heard Google Docs collaboration ran through XMPP + Ajax. The chat and online status of Facebook is just XMPP. There are some other games like ChessPark I'm sure you can find out there.

Myself, I've used XMPP to handle presence and chat for MMO's, pretty sure Dota uses XMPP for their chat also. I've also written various status systems using XMPP, server down, starting, locked, up, etc or build success, failure, etc by simply pushing status messages into nodes on the XMPP server that a web page could subscribe to and watch. I've even used the pubsub on nodes to control distributed build processes such as send a build request to a node, an XEP or module picks that up and sends out builds to workers on various machines which report the status back eventually and even zip up artifacts and send them somewhere the user can grab the results.

Overall, it is a great tool and can be used in many ways beyond what folks think of when they see "Jabber".

I know of no XMPP server that bakes in the things you're talking about; you'd have to add it into some existing server by changing the server.

That's certainly possible, but at that point, you're no longer XMPP, you're some custom client and server that happen to use XMPP for transport.

In my mind, transport is the simplest problem to solve, so using XMPP (and living within the XMPP server and client libraries you choose) may cost more than it gives you.

The fastest way to get to where you say you want to go is probably an existing cloud service platform, such as Parse (mobile focused) or Gamedonia (game focused.)

I haven't used Gamedonia, but someone suggested it earlier in the forums, and once you can find your way to its documentation, it seems like a reasonable option.

enum Bool { True, False, FileNotFound };

I know of no XMPP server that bakes in the things you're talking about; you'd have to add it into some existing server by changing the server.
That's certainly possible, but at that point, you're no longer XMPP, you're some custom client and server that happen to use XMPP for transport.

You might want to look at the XMPP servers again as all of the ones I've looked at and used implement: XEP-0060 publish-subscribe nodes (http://xmpp.org/extensions/xep-0060.html) and XEP- 0124 BOSH html connections (http://xmpp.org/extensions/xep-0124.html). EJabberD for instance: http://www.ejabberd.im/protocols, as you can see not only are they both implemented they are both on by default in a standard installation. The list of servers I know have those built in XEP's (pubsub enabled by default. bosh sometimes but available): jabberd2.0 (not related to the above ejabberd), Openfire, Citadel, Prosidy, Vines and I'm quite sure others, though this is pretty much your list of the most common servers.

Given you need nothing more to do everything I mentioned, there is no particular reason to think XMPP is any more or less complex to use than any of the other solutions you mention. A "game" can be written as nothing more than a client and XEP service written in just about any language you want.

As a silly example, her's tic tac toe in XMPP played via web browser: https://github.com/metajack/profxmpp/tree/master/ch11

Obviously a downside to XMPP is that being a XML transport it is heavy weight, but that of course allows it to work over HTTP easily so perhaps it is not a downside.

Addition: forgot to list XEP-0045 for the multi-user chat room ability he requested. Again, that list of servers all have this.

XMPP pubsub does not solve the server-side rules enforcement problem. You need a custom module for that.

It also doesn't solve the Facebook integration problem -- in fact, it makes it harder, as you have to tie multiple identities together.

enum Bool { True, False, FileNotFound };

XMPP pubsub does not solve the server-side rules enforcement problem. You need a custom module for that.

It also doesn't solve the Facebook integration problem -- in fact, it makes it harder, as you have to tie multiple identities together.

For the rules enforcement, as mentioned, just write an external XEP service using any of a number of frameworks available for many different languages. In the posted silly example, the rules are enforced by a second browser connected to the server which controls the game. Kinda inefficient to do it that way but basically the same pattern can be used without needing to actually "plug into" the server. Python has a very nice external XEP solution, it just connects with a service account so it can create/own nodes.

I didn't notice the facebook desire, but there are plenty of existing XEP's for the various servers which will do that. A little Googling suggested it would take about 10 minutes to add it, configure it and then use FB as your login. Seemed pretty simple, might try it on my server for fun.

Understand, I'm not against the suggested frameworks you mentioned at all or arguing that XMPP is some silver bullet and better in some way, but from a brief perusal at least one of the suggested frameworks shows strong hints that it is or was an XMPP serverand they just added more features and an easier API instead of the XML stanza's. For most purposes though, there are plenty of existing XEP's to support most things and existing frameworks to make writing custom ones extremely simple. It's the flexibility to turn it into whatever you want with a large existing support base which makes me suggest taking an unbiased look at it. Not to mention the proven scalability seen with Google and Facebook using it along with many MMO's (though just for presence and chat usually) and a number of other online games ranging from the given Chess to many of the online poker games.

This topic is closed to new replies.

Advertisement