Android P2P Multiplayer game (with a) XMPP/Google talk b) JXTA peerdroid c) other way)
Asked Answered
I

4

24

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

Isomerize answered 4/3, 2010 at 19:56 Comment(2)
I'm assuming there's a relatively small amount of players at once, so one phone should be able to act as a server to the others, especially since boardgames are turn-based the amount of network traffic is minimal. But you still need some centralized form of discovering other players. (i.e personally I wouldn't go with P2P at all in this case)Heterosexuality
I don't know your requirements, but if you expect people to be in proximity to each other, you could use something like Bump to handle the data connection...Sexdecillion
A
4

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.

Antiquated answered 21/10, 2010 at 21:12 Comment(0)
T
3

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.

Thomajan answered 5/3, 2010 at 8:45 Comment(4)
Actually, the Android XMPP Library IS smack. :-)Jennet
I can't find any xmpp libs on developer.android.com could you provide a link to the library that is preinstalled in android?Thomajan
AFAIK there are no xmpp libs in android! And the gtalkservice was removed starting from android 1.0Isomerize
Does anybody has an example on how to create a multiplayer game using the existing google talk service ?Isomerize
F
3

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.

Fellowman answered 30/6, 2010 at 3:40 Comment(0)
P
1

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.

Pessa answered 10/6, 2011 at 13:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.