read sfsobject on login extension client side

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

Moderators: Lapo, Bax

Skills07
Posts: 103
Joined: 07 Nov 2016, 14:54
Location: Italy

read sfsobject on login extension client side

Postby Skills07 » 02 Jul 2018, 07:22

Hello everybody i've done a login extension integrated with my db and all works properly.

But i have a question:

on my server extension i create this object :

Code: Select all

ISFSObject outData = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_OUT_DATA);
 while(res.next())
         {
             
             int id_user = res.getInt("id_user");
             trace(id_user);

            String username = res.getString("username");
            trace(username);
            
            String email = res.getString("Email");
            trace(email);

            int mkoin = res.getInt("mkoin");
            trace(mkoin);
            
            String profile_img = res.getString("profile_img");
            
            if(profile_img == null){
               profile_img = "";
            }
            trace(profile_img);
            
            
            
            outData.putInt("id_user", id_user);
            outData.putUtfString("nome_utente", username);
            outData.putUtfString("email", email);
            outData.putInt("mkoin", mkoin);
            outData.putUtfString("profile_img", profile_img);
            outData.putUtfString(SFSConstants.NEW_LOGIN_NAME, username);

}


how can i read this object?

on client side i need to read this to take some information to print on the screen.

Thanks to all
User avatar
Lapo
Site Admin
Posts: 20426
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: read sfsobject on login extension client side

Postby Lapo » 02 Jul 2018, 08:00

From client side, in the SFSEvent.LOGIN event you get a "data" object represent the data you've sent from the server.
(see the doc for that event if you need more details)

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Skills07
Posts: 103
Joined: 07 Nov 2016, 14:54
Location: Italy

Re: read sfsobject on login extension client side

Postby Skills07 » 02 Jul 2018, 08:25

Lapo wrote:From client side, in the SFSEvent.LOGIN event you get a "data" object represent the data you've sent from the server.
(see the doc for that event if you need more details)

Cheers


Sorry Lapo, but i have always done Server side parts, but in this project i need to do client and server parts.
on client i have this function

Code: Select all

private void OnLogin(BaseEvent evt)
    {

        SFSObject myData = (SFSObject)evt.Params["params"];
       

        Debug.Log("ARRAY :" + myData);
       
        User user = (User)evt.Params["user"];

        // Show system message
        string msg = "Connection established successfully\n";
        msg += "SFS2X API version: " + sfs.Version + "\n";
        msg += "Connection mode is: " + sfs.ConnectionMode + "\n";
        msg += "Logged in as " + user.Name;
        Debug.Log(msg);


       
        // Join first Room in Zone
        if (sfs.RoomList.Count > 0)
        {
            sfs.Send(new Sfs2X.Requests.JoinRoomRequest(sfs.RoomList[0].Name));
        }

        StartCoroutine(LoadAsynchronously(sceneIndex));
    }


how can i read my OutData object sended from the server??
User avatar
Lapo
Site Admin
Posts: 20426
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: read sfsobject on login extension client side

Postby Lapo » 02 Jul 2018, 09:14

Code: Select all

SFSObject data = (SFSObject) evt.Params["data"];
Lapo

--

gotoAndPlay()

...addicted to flash games
Skills07
Posts: 103
Joined: 07 Nov 2016, 14:54
Location: Italy

Re: read sfsobject on login extension client side

Postby Skills07 » 02 Jul 2018, 10:39

Solved thanks :)

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 24 guests