How to get login out data

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

powerLed
Posts: 3
Joined: 03 Jul 2016, 16:02

How to get login out data

Postby powerLed » 03 Jul 2016, 16:21

Hi guys. I have some problems. I hope you can help me. When I logged in the server I want to get user information from the server. Everything is fine I created the data as Json and I can trace it.

After that in login handler

Code: Select all

ISFSObject outData = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_OUT_DATA);

and I put the Json data as string into outData. But when I check the outData in Login Event(in Unity) always return null.

I tried to Add LogListener and I can see my json data in message which comes.

Code: Select all

sfs.AddLogListener(LogLevel.INFO, OnLogLevelInfo);
        private void OnLogLevelInfo(BaseEvent evnt){
      string message = (string)evnt.Params["message"];
      Debug.Log(message);
      Debug.Log((SFSObject)evnt.Params["params"]);
   }

You can see the picture of console. So finally How can I get login out data in client side. Pls help me.
Thanks for everything.. :D
Attachments
Report.jpg
Console Output
(79.88 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to get login out data

Postby Lapo » 04 Jul 2016, 08:06

Hello,
inside your LOGIN event handler, client side, you just need to do this:

Code: Select all

private void OnLogin(BaseEvent evt)
{
   User user = (User) evt.Params["user"];
   ISFSObject loginData = (ISFSObject) evt.Params ["data"];
   
   // ... etc...
}


"data" contains the object you have sent from server side. These parameters are all documented under the SFSEvent class in the C# docs.
http://docs2x.smartfoxserver.com/api-docs/csharp-doc/

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 25 guests