How send array and varchar in the same object

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

Moderators: Lapo, Bax

TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

How send array and varchar in the same object

Postby TwineApps » 21 Apr 2017, 09:55

Hi,

How can I send an array from the server and follow a varchar in the same object?

Code: Select all

try{

         ISFSArray arr =   dbmanager.executeQuery(sql,
                        new Object[] {});
         
         if (arr.size() > 0)
         {
             
            SFSObject result = new SFSObject();
            result.putSFSArray("success", arr);
            send("returnchat", result, user);
             
             
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date = new Date();
            dateFormat.format(date);
            SFSObject result2 = new SFSObject();
            result2.putUtfString("success", dateFormat.format(date));
            send("returnchat", result2, user);
             
         }
   }catch (SQLException e) {
     
      ISFSObject error = new SFSObject();
      error.putUtfString("error", "MySQL update error");
      send("returnchat" , error, user);
      e.printStackTrace();
      trace(e.toString());
   }


Yours sincerely
User avatar
Lapo
Site Admin
Posts: 19646
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How send array and varchar in the same object

Postby Lapo » 21 Apr 2017, 10:10

You have already asked this in a private message.
Just put the two objects (array and string) into the same SFSObject and send it.
Lapo
--
gotoAndPlay()
...addicted to flash games
TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

Re: How send array and varchar in the same object

Postby TwineApps » 21 Apr 2017, 10:24

How can this be done? Can you give me an example?

Greetings
TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

Re: How send array and varchar in the same object

Postby TwineApps » 21 Apr 2017, 12:19

Can someone help me?
TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

Re: How send array and varchar in the same object

Postby TwineApps » 21 Apr 2017, 12:28

I did this code, but the client just comes the date:

Code: Select all

SFSObject result = new SFSObject();
result.putSFSArray("success", arr);
result.putLong("success", data);
send("returnchat", resukt, user);
User avatar
Lapo
Site Admin
Posts: 19646
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How send array and varchar in the same object

Postby Lapo » 21 Apr 2017, 13:39

You're using the same key for two different parameters...
Lapo

--

gotoAndPlay()

...addicted to flash games
TwineApps
Posts: 80
Joined: 10 Nov 2016, 18:39

Re: How send array and varchar in the same object

Postby TwineApps » 21 Apr 2017, 13:53

Lapo solved my mystery, thank you very much

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 13 guests