Smack for Gaming, need some advice

Hello Everyone!

I have a probably different request for everyone. First off i am wanting to use XMPP/Smack for an Android game i want to develop.

The game is a turnbased multiplayer game, i am wanting to use XMPP/Smack for all Server Side information storage and client-client communication. But i am having trouble deterimining how to use the api’s for what i want to do.

First i am going to use the Roster as well…a roster lol, then use a “Chat” for sending information from-to clients. Then im going to use PrivateDataManager to store player information.

My problem comes in that for each “game”(which in being turn based can be over may sessions/hours/days/) to have a place where even if the other player is offline one can go to get that games current game information. I want as a backup for if a game some how loses its state. But i have not found a way using the api to share data between two specific users. I have on doubt that it is possible but the problem comes from my lack of understanding of the api.

Any help would be greatly apricated .

Can’t say if this is the best approach, but you can use a persistent pubsub node to store the game information.

Most likely an android specific problem but when ever i try and create a node i get this error

05-17 16:29:41.429: WARN/System.err(8941): conflict(409)

05-17 16:29:41.429: WARN/System.err(8941): at org.jivesoftware.smackx.pubsub.packet.SyncPacketSend.getReply(SyncPacketSend.ja va:53)

05-17 16:29:41.429: WARN/System.err(8941): at org.jivesoftware.smackx.pubsub.packet.SyncPacketSend.getReply(SyncPacketSend.ja va:61)

05-17 16:29:41.429: WARN/System.err(8941): at org.jivesoftware.smackx.pubsub.PubSubManager.sendPubsubPacket(PubSubManager.jav a:324)

05-17 16:29:41.429: WARN/System.err(8941): at org.jivesoftware.smackx.pubsub.PubSubManager.sendPubsubPacket(PubSubManager.jav a:318)

05-17 16:29:41.429: WARN/System.err(8941): at org.jivesoftware.smackx.pubsub.PubSubManager.createNode(PubSubManager.java:134)

05-17 16:29:41.439: WARN/System.err(8941): at org.jivesoftware.smackx.pubsub.PubSubManager.createNode(PubSubManager.java:103)

caused by

PubSubManager mgr = new PubSubManager(connection);

try

{

LeafNode leaf = mgr.createNode(“testNode”);

}

catch (XMPPException e) { e.printStackTrace(); }

I am pretty certain others have used this on Android, but I can’t say that the stack posted is very helpful for debugging.

Ok an update, i have gotten through most of my issues tho i am still having trouble reciving infromation from a node.

this code http://pastebin.com/yBSsLQzB

creates this output http://pastebin.com/p7DxXt1P

idk if there is a problem with smack or my code or the server. Running newest OpenFire.

OK i seem to have fixed most of my issues like changing…

mgr = new PubSubManager(connection);

to…

mgr = new PubSubManager(connection,“pubsub.” + connection.getServiceName());

Mayb bc im testing off my local pc? idk ether way that issue is behind me lol. One last issue

LeafNode nod2= mgr.getNode(“NODENODE”);//yea yea test name

Collection<? extends Item> items = null;

try {

items = nod2.getItems();

Log.i(“XMPPClient”, “Recieved Items”);

} catch (XMPPException e) {

Log.e(“XMPPClient”, “[SettingsDialog] Failed to get payload”);

Log.e(“XMPPClient”, e.toString());

}

throws “bad-request(400)” with the following packets

http://pastebin.com/wcpSY32F

Which is interesting bc the information is being recieved but the error is being thrown…mayb android specific?

EDIT: Inserting a Subid fixed issue. Thread can be closed if need be .

ED

What version are you using?

The defaut behaviour was changed in version 3.2 to use “pubsub” + connection.getServiceName(). So your initial creation of the PubSubManager should work.

3.1 so that was probably the issue(something i should have included in the OP…woops lol).

I now got everything fully working, now im trying to use a BOSHConnection. I have managed to get the connection up & running and log in. But PubSub is having some problems, sometimes it will recieve nodes sometimes it wont. But it will NEVER create a node. I have isolated the Shazma being sent and they appear to be exactly the same in context.

So i am guessing the problem is with the initial connection as the shazma being sent is the same. Is anyone knowledgeable enough with pubsub server side to know whats going on?

Edit1:Ok update, it seems after i login any request seems to time out(unless the servers ping request comes in, then it will get the reply and move on). All requests after the one that timed out work…

Any ideas? Would this be a server issue?

Edit2: Ok was not able to repoduce with pure java on my pc, so it its android specific(doh!). Have to track down android specific bosh changes, will report back.

Ok i figured out both issues and will put them in here in case any others have the same issues.

First problem was not being able to get a good PubSub Connection, this was caused by the fact that i was using Smack 3.1, It has been fixed in 3.2 by changing the default construction to.

mgr = new PubSubManager(connection,“pubsub.” + connection.getServiceName());

Second problem was class cast exceptions when trying to recieve any pubsub info. This has been discussed before. It is caused by the provider manager not being able to load the provider list. I got around this by(by using a patch from this forum) placing the smack.providers file somewhere else on the device(since this is all on android in my case) and then defining its path via a system property.

Third was BOSHConnection pubsub requests always timing out. This was a specific issue related ot the smack-bosh port to android. The default httpsender was replaced with apache version becaues the default had to load a file from resources like with the provider manager. I added back the original code for BOSH then replaced the file loading to the same way as i did on the provider manager, defining it via a system property. Once the default implementation was in place and the file loaded successfully it worked as expected.