Multi dimensional array in Smartfoxserver 2x (Java API)

Posted by & filed under Action Script 3, Java, SmartFox Server.

This is simple example how to use multi dimensional array in SmartFoxServer actionScript 3 API as well Java API. I am using actionScript 3 API on the client, on the server side I’m using Java API to get that value the client sent.

multi dimensional array in smartfoxserver 2x

Multi Dimensional Array in SmartFoxServer 2x

 

Here is client side multi dimensional array.

var questionFeedback:ISFSObject= new SFSObject();

var answers:ISFSArray = new SFSArray();
answers.addIntArray([1,1,0]);
answers.addIntArray([2,1,0]);
answers.addIntArray([3,1,0]);
answers.addIntArray([4,1,0]);
answers.addIntArray([5,0,1]);
answers.addIntArray([6,1,0]);
answers.addIntArray([7,1,0]);
answers.addIntArray([8,1,0]);
answers.addIntArray([9,1,0]);

questionFeedback.putSFSArray(‘answers’,answers);
sfs.send(new ExtensionRequest(“sendQuestionFeedback”,questionFeedback));

Here is the server side Java code. We are sending multi dimensional SFSArray to server, While getting the multi dimensional SFSArray on the server side we need to convert that SFSArray into array collections then into normal array. You will get an idea while go through the below java code..

ISFSArray answers= params.getSFSArray("answers");
for(int i=0;i<answers.size();i++)
{
Collection e= answers.getIntArray(i);
Object[] b= e.toArray();
int questionID= (Integer) b[0];
int like = (Integer) b[1];
int disLike = (Integer) b[2];
trace("questionID----------"+questionID);
trace("like----------------"+like);
trace("disLike-------------"+ disLike);
}

 .

Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts

If you want any of my script need to be customized according to your business requirement,

Please feel free to contact me [at] muni2explore[at]gmail.com

Note: But it will be charged based on your customization requirement

Get Updates, Scripts & Other Useful Resources to your Email

Join 10,000+ Happy Subscribers on feedburner. Click to Subscribe (We don't send spam)
Every Email Subsciber could have access to download 100+ demo scripts & all future scripts.

Get Instant Script Download Access!