Site icon SmartTutorials.net

Two dimensional array in Smartfoxserver 2x (Java API)

This is simple example how to use two 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.

Two Dimensional Array in SmartFoxServer 2x

Here is client side two dimensional array………..

var gameScore:ISFSObject= new SFSObject();

var score:ISFSArray = new SFSArray();
score.addIntArray([1,1]);
score.addIntArray([2,2]);
score.addIntArray([3,3]);

gameScore.putSFSArray(“score”,score);
sfs.send(new ExtensionRequest(‘getGameScores’, gameScore));

Here is the server side Java code. We are sending two dimensional SFSArray to server, While getting the two 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 score= params.getSFSArray("score");
for(int i=0; i<score.size();i++)
{
	Collection e= score.getIntArray(i);
	Object[] b= e.toArray();
	int questionId= (Integer) b[0];
	int languageId = (Integer) b[1];
}

 

 

 

 .

Exit mobile version