How to send SFSObject to loginError event?

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

poxu
Posts: 4
Joined: 06 Jul 2018, 12:54

How to send SFSObject to loginError event?

Postby poxu » 06 Jul 2018, 13:08

I have some unusual cases in which user can't login.
More specifically I have to send a lot of data to the client to describe actions to be taken to login.

What I would like to do is to somehow send SFSObject as an argument to loginError event.
I want to write something like that on server side


Code: Select all

ISFSObject reason = new SFSObject();
reason.putUtfString("message", "You're late");
reason.putUtfString("action", "Come back later");
reason.putInt("hoursToWait", 10);

SFSErrorData errorData = new SFSErrorData(SFSErrorCode.GENERIC_ERROR);
errorData.setParams("reason", reason);
throw SFSLoginException("Too late", errorData);


And then, get reason as SFSObject on client side when processing loginError event. Right now I'm going to send JSON string to client, which is weird, considering, that SmartFox has SFSObject for such things.

Can I do that somehow

P. S. I wanted to make some other event first as a workaround, but as far as I understand I can't send any Zone Events before I have successfully logged in.
User avatar
Lapo
Site Admin
Posts: 20959
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to send SFSObject to loginError event?

Postby Lapo » 06 Jul 2018, 13:27

Hi,
if users can't login you should find the details in the server side logs.

Unfortunately it's not possible to send custom objects as errors, because the error system is based on error codes and a relative "translation table", so that you can localize the error messages.

I'd recommend checking the logs first for further details.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
poxu
Posts: 4
Joined: 06 Jul 2018, 12:54

Re: How to send SFSObject to loginError event?

Postby poxu » 06 Jul 2018, 14:16

if users can't login you should find the details in the server side logs.

Well, I have to let client know why user can't login. Suppose some users are only permitted to login at night and some only at daytime.

Unfortunately it's not possible to send custom objects as errors, because the error system is based on error codes and a relative "translation table", so that you can localize the error messages.

I don't mind using code 28, which is a GENERIC_ERROR. And it wouldn't break anything, if I could add custom object. errorMessage would be translated, and my custom object would be just passed to a client intact. Obviously translation table is not the reason for not being able to pass objects along errors :).

I guess I have to continue using JSON.
User avatar
Lapo
Site Admin
Posts: 20959
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to send SFSObject to loginError event?

Postby Lapo » 07 Jul 2018, 05:39

poxu wrote:Well, I have to let client know why user can't login. Suppose some users are only permitted to login at night and some only at daytime.

You can send a custom error message with the details of the problem.
viewtopic.php?f=18&t=14390

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
poxu
Posts: 4
Joined: 06 Jul 2018, 12:54

Re: How to send SFSObject to loginError event?

Postby poxu » 13 Jul 2018, 08:09

You can send a custom error message with the details of the problem
.

No, you actually can not. At least if you're using Java Client API. The List, containing error messages is fixed in size and trying to get a message for non standard error code produces NPE.
User avatar
Lapo
Site Admin
Posts: 20959
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to send SFSObject to loginError event?

Postby Lapo » 13 Jul 2018, 16:01

Thanks for providing more details.
I am going to move this thread under the right section: SFS2X Java/Android API

We'll verify the problem with the API and release a quick update during the next week.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 20959
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to send SFSObject to loginError event?

Postby Lapo » 17 Jul 2018, 08:39

UPDATE:
An update of the Java API (ver 1.7.3) is available for download with the fix relative to the problem you've pointed out.

See here:
viewtopic.php?f=22&t=20732

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 1 guest