Collection<Integer> is null

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

claudiu.m
Posts: 23
Joined: 10 Sep 2013, 08:51
Location: Germany

Collection<Integer> is null

Postby claudiu.m » 24 Sep 2013, 14:17

Hello,

i am trying to send an array of integers to the server.
On the client side i have done it like this:

Code: Select all

 var myarr = {positions:this.pos_arr};
            this.sfs.addEventListener(SFS2X.SFSEvent.EXTENSION_RESPONSE, this.new_positions,this);
            this.sfs.send(new SFS2X.Requests.System.ExtensionRequest(DICE_GAME.GAME_COMMANDS.GAME_START,myarr));


The compiler shows the OUTGOING DATA:

Code: Select all

[INFO] OUTGOING DATA
p: [Object]
   p: [Object]
      positions: [Array]
         19: 1216 (Num)
         18: 1152 (Num)
         17: 1088 (Num)
         16: 1024 (Num)
         15: 960 (Num)
         14: 896 (Num)
         13: 832 (Num)
         12: 768 (Num)
         11: 704 (Num)
         10: 640 (Num)
         9: 576 (Num)
         8: 512 (Num)
         7: 448 (Num)
         6: 384 (Num)
         5: 320 (Num)
         4: 256 (Num)
         3: 192 (Num)
         2: 128 (Num)
         1: 64 (Num)
         0: 0 (Num)
   r: -1 (Num)
   c: 0 (Str)
c: 1 (Num)
a: 13 (Num)


But on the server I am not able to get this integers into a Collection of Integers.
On the server the code looks like this:

Code: Select all

public class StartGame extends BaseClientRequestHandler {

   @Override
   public void handleClientRequest(User player, ISFSObject params) {
      // TODO Auto-generated method stub
      try {
         ServerGameExtension ext = (ServerGameExtension) getParentExtension();
         
         ext.getGame(player,params);
         
         Collection<Integer> myarr  = params.getIntArray("myarr");
         


The variable myarr is null.
Do you have any ideea how to get that integers?
Thank you in advance for your help.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Collection<Integer> is null

Postby Lapo » 24 Sep 2013, 19:39

You are using wrong key :)
You have created an Object that contains an array of numbers called "positions". myarr is just the name of your local variable in Javascript.
The key to use is positions.

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
claudiu.m
Posts: 23
Joined: 10 Sep 2013, 08:51
Location: Germany

Re: Collection<Integer> is null

Postby claudiu.m » 25 Sep 2013, 13:30

Hi Lapo,
sorry about this dumb questions but I am new to programming and OOP and networkprogramming is for me now overwhelming.
Thank you for taking your time to answer such questions.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Collection<Integer> is null

Postby Lapo » 25 Sep 2013, 14:07

No problem, take one step at a time :)
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 101 guests