Some uberNoob q's about aSmack,Smack,and XMPP server

Hi to all,

I am a very novice programmer who is experimenting with Smack and XMPP as a way to create cross-device communication for a turn based android chess game. Most of the discussion here seems way over my head so I hope this doesn’t insult people’s intelligence.

First just to make sure my idea seems valid:

User creates username and password for online play in the game. Game registers that username(modifed to improve uniqueness) and password with a Jabber server using AccountManager.createAccount(username,password). After one can create a buddylist of other players and basically the game sends XMPP messages between the apps on each phone to convey the moves selected. Each time the user starts the app it logs into the server and receives any messages that may have been sent when it was offline and updates the games accordingly.

This would just use the most basic functionality of XMPP and should be easy right.

I’m using aSmack as it seems capable of this. I just started by trying to create a test account on a free server:http://www.macjabber.com/manual-psi/ and have hit a snag. Here is my code:

ConnectionConfiguration config = new ConnectionConfiguration(“macjabber.de”, 5222);
connection = new XMPPConnection(config);

try{connection.connect();}
catch(Exception e){Log.e(“connection”,"XMPP exception " + e.toString());}

am = connection.getAccountManager();//new AccountManager(connection);
if(am.supportsAccountCreation() == true){
Log.d(“AM”,“Trying to create Account”);
String instr = am.getAccountInstructions();
Log.d(“AM”,instr);
Collection c = am.getAccountAttributes();
for(String s : c){
Log.d(“Attributes”,s);
}

try{am.createAccount(“kmomochesstest”, “password1”);}
catch(Exception e){Log.e(“connection”,"Account Creation error: " + e.toString());}
}

A couple general XMPP q’s first:

Should the username submitted include the domain or not?

Is there any stipulation on length of either username or password?

Anyway when I call createAccount I get back a “bad-request (400)” error in the catch block. I have a couple Log statements to check what info the server needs and they all seem to say it only needs username and password. Someone seemed to have posted a similar issue here:

His solution is just to move the for each loop over the Attribute key set to before the calls to setUsername and setPassword as he found the method is passing them as null.

1)Is there an easy way to see if the default .jar is passing null values?

2)Can someone expain why moving this code would fix it? It seems hard to believe that such a basic and common task has a bug like this

3)Does anyone know a good tutorial on updating Referenced libraries in Eclipse so as to update the asmack.jar? I don’t have much experience in this and just editing the souce doesn’t work.

If anyone can give me some pointers it’d be great as I know this is long and probably mudane.

Ok, reading the code in AccountManager and Registration more closely it seems my call to createAccount(username,password), calls createAccount(username,password,attributes) passing a attribute Map with keys “username” & “password” set to null, or at least “”. Then after setting the attributes in the Registration object the for each loop then wipes them out with the null values in attributes passed. Retarded.

So yeah any tips on how to change the asmack.jar with Eclipse is appreciated.

And just calling the 3 argument version of createAccount() with an empty HashMap seems to bypass the issue. I stil don’t see how this slipped through.

Any feedback on my other q’s would still be appreciated.

Another one is:

If I call createAccount with a username thats already being used will I get back I detailed exception?

I ran the program again and i gave me a resource constraint error 500 saying “users are not allowed to register accounts so quickly”…