I have received LOGIN_IN_DATA but how can i send back LOGIN_OUT_DATA. I am working on a server emulator for CPI.
Thanks
How to send data back
Re: How to send data back
Hi,
the LOGIN_OUT_DATA object is passed in the SFSEvent.USER_LOGIN event.
Check the docs here:
http://docs2x.smartfoxserver.com/Extens ... -assistant
Section #4, specifically.
Cheers
the LOGIN_OUT_DATA object is passed in the SFSEvent.USER_LOGIN event.
Check the docs here:
http://docs2x.smartfoxserver.com/Extens ... -assistant
Section #4, specifically.
Cheers
Re: How to send data back
Lapo wrote:Hi,
the LOGIN_OUT_DATA object is passed in the SFSEvent.USER_LOGIN event.
Check the docs here:
http://docs2x.smartfoxserver.com/Extens ... -assistant
Section #4, specifically.
Cheers
i know but how can i send data back with LOGIN_OUT_DATA using LOGIN_IN_DATA data
Thanks
Re: How to send data back
tulparid wrote:i know but how can i send data back with LOGIN_OUT_DATA using LOGIN_IN_DATA data
Just get the SFSObject from the event and add to it. Everything you add will be returned.
Here's an example from my code:
Code: Select all
// get SFSObject provided to return a new name to the client after login
ISFSObject outData = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_OUT_DATA);
outData.putUtfString(SFSConstants.NEW_LOGIN_NAME, username);
outData.putByteArray(PARAM_KEY_PROTOBUF, responsePb);
hth
Re: How to send data back
Luke64 wrote:tulparid wrote:i know but how can i send data back with LOGIN_OUT_DATA using LOGIN_IN_DATA data
Just get the SFSObject from the event and add to it. Everything you add will be returned.
Here's an example from my code:Code: Select all
// get SFSObject provided to return a new name to the client after login
ISFSObject outData = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_OUT_DATA);
outData.putUtfString(SFSConstants.NEW_LOGIN_NAME, username);
outData.putByteArray(PARAM_KEY_PROTOBUF, responsePb);
hth
well i tried this but looks like it didn't really work.
Code: Select all
String login_in_data_json = "{stringified json of login in data here}";
byte[] bytes = login_in_data_json.getBytes();
ISFSObject outData = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_OUT_DATA);
outData.putUtfString(SFSConstants.NEW_LOGIN_NAME, name);
outData.putByteArray("outData", bytes);
Re: How to send data back
Why are you saying it didn't work?
Do you have an error? If so post the details, please.
Are trying to read the received data correctly?
On the client side you need to do something like this:
This is C#, if you're using a different platform let me know.
Cheers
Do you have an error? If so post the details, please.
Are trying to read the received data correctly?
On the client side you need to do something like this:
Code: Select all
public void OnLoginData(BaseEvent evt)
{
ISFSObject sfso = (ISFSObject) evt.Params["data"];
sfso.getByteArray("outData");
...
}
This is C#, if you're using a different platform let me know.
Cheers
Re: How to send data back
Lapo wrote:Why are you saying it didn't work?
Do you have an error? If so post the details, please.
Are trying to read the received data correctly?
On the client side you need to do something like this:Code: Select all
public void OnLoginData(BaseEvent evt)
{
ISFSObject sfso = (ISFSObject) evt.Params["data"];
sfso.getByteArray("outData");
...
}
This is C#, if you're using a different platform let me know.
Cheers
I don't have any error, I am trying to write received data back using LOGIN_OUT_DATA
Re: How to send data back
Please show the server side code used to send the data and the relative client side handler that reads the data in the login handler.
Thanks
Thanks
Who is online
Users browsing this forum: No registered users and 37 guests