Monday, June 17, 2013

Private Chat packets(reversal)

While it makes sense, it's worth noting that when A sends a private chat to B, the 'from' variable = A and 'room' variable = B. This also happens vice-versa. The issue here is that since ALL messages are broadcasted across the users, then 'room' value keeps changing. Sample this

1. Broadcast message from me

processPacket...{"ref":"chat","mod":"chat","status":200,"err":null,"result":{"type":"p","ctype":"t","id":"2E3QW1AW34ay7y410wfQ","msg":"Hey, please send another message","from":"254712249559","room":"233200238442","coord":null,"ts":"1371461833"}}
Reading data...

2. Broadcast message from friend with reply
processPacket...{"ref":"3_faaa586c9aa38f01968715d762e3c995","mod":"chat","status":200,"err":null,"result":{"type":"p","ctype":"t","id":"2E3QWagtWQM0RYWluxOK","msg":"another message","from":"233200238442","room":"254712249559","coord":"5.645256:-0.151525","ts":"1371461857"}}
Reading data...

As seen, the 'room' variable keeps changing. To handle this change:
1. Check if chat is private
2. Check that chat is not from me
3. Apply room reversal


/*
             * Handle reversal for private chat--arghh!!!!
             *
             */
            if(json.getJSONObject("result").getString("type").equals("p")){
                //Check if message is not from me and reverse roomid
                if(!json.getJSONObject("result").getString("from").equals(phone)){
                    roomid = json.getJSONObject("result").getString("from");
                }
            }
            

java.io.IOException: error 32 during TCP write


On netbeans project.Right click on project->properties->manage emulators->tools & extensions-> and changing the Http Version from HTTP1.1 to HTTP1.0. This works in Sun Wireless Toolkit 2.5.2.


Saturday, June 15, 2013

Cleaning up final app

Been cleaning, tweaking and generally finalizing the app for submition. One think pointed out by Mawuli is the fact that non-English speakers will find it hard to use the app and therefore am customizing to accommodate them.

One of the changes revolves around the registration process where the (English)language is being simplified and also the process made more fool proof by providing a means for the user to choose which country they are in. This brings onboard a some complexities,namely file size increase and code refactoring.

I've attached a CSV file(countrycodes.txt) as a resource in the images folder which contains international dialing codes for all countries. The file has increased the overall app size by 3.5kb.

Since users are not mandated to append their international dialing codes to their numbers, I have to curate the number and country chosen so as to come up with a valid mobile number. Below is the guidance am employing in this task.


All mobile numbers need to be entered in this format.
Coutry Code, Network prefix (no leading 0), Mobile Number.
For example, the mobile number 072 244 3259 in South Africa would be formatted like this:


//www.digitalsms.net/faq/numberformat/index.php