Sending key value pair in smartfox error

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

Moderators: Lapo, Bax

Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Sending key value pair in smartfox error

Postby Hassan Khallouf » 06 Jul 2017, 05:20

Hello,
we have an old and complicated system working on smart fox pro, and we are planning the move for smart fox 2
I'm trying to make a custom login handler, but our login function is a bit complicated
the additional data (LOGIN_OUT_DATA) you can send in the login is sufficient to send the the info we need

However, when we throw an error a login error, LOGIN_OUT_DATA is not sent to the client
we need some key value pair mechanism with the error callback

for example this is one of the errors we have:
Error: user should go to specific server, and we need to pass with it ("serverId", 1)

in sfs pro we used to send extension response for both success and failure, but there are 2 problems in sfs2
1- I want to follow the convention and use the mechanisms provided by smart fox
2- we used to send them as json, I don't want to use json only for this since SFS2 uses ISFSObject
3- we can't send extension response since in sfs2 User is null in the login handler while it wasn't in sfs pro, so I can't use send method

any suggestions to tackle this problem?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Sending key value pair in smartfox error

Postby Lapo » 06 Jul 2017, 15:59

Hi,
the error event is supposed to provide a custom error message but doesn't include custom data.

Do you need the data for some kind of logic in your client or do you just need to customize the error message so that it includes that data?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: Sending key value pair in smartfox error

Postby Hassan Khallouf » 08 Jul 2017, 08:37

Thanks for answering lapo

we need it for logic in the client side
as I mentioned in the example, if the user isn't allowed in one of our servers (we have 10 sfs servers), the server returns the error message of why the user isn't allowed, and it returns the server id the the client should be redirected to

this is an example, we have 2 or 3 errors like this

thanks again
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Sending key value pair in smartfox error

Postby Lapo » 08 Jul 2017, 14:10

Since you can customize the string error message, I would suggest to use that as the "transport" for the data you need on client side.
The string could contain a number of parameters separate by commas or any other token.
http://docs2x.smartfoxserver.com/Advanc ... r-messages

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: Sending key value pair in smartfox error

Postby Hassan Khallouf » 09 Jul 2017, 06:05

I'm familiar with that, and I know I can send custom errors
but doesn't that mean the client needs to parse the errors from strings?
this is not a very good approach
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Sending key value pair in smartfox error

Postby Lapo » 09 Jul 2017, 16:34

At least it is an effective workaround.
I have added an entry in our TODO list to support sending separate custom data in login errors.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: Sending key value pair in smartfox error

Postby Hassan Khallouf » 10 Jul 2017, 06:24

thanks Lapo

I will send the info in extensionResponse for the mean time

thanks again :)
Hassan Khallouf
Posts: 41
Joined: 06 Jul 2017, 04:35

Re: Sending key value pair in smartfox error

Postby Hassan Khallouf » 11 Jul 2017, 06:32

Hello again,
I forgot what I already mentioned
I can't send onExtensionResponse for users when the login fails because user object is still null

in sfs pro we used to send the data using the SocketChannel even when the user is null, it seems there is no similar approach in SFS2 ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Sending key value pair in smartfox error

Postby Lapo » 11 Jul 2017, 07:06

Hi,
No that's why I suggested the workaround in my previous post.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 58 guests