Invalid value passes error when sending float in SFSObject from server

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

Moderators: Lapo, Bax

pratts
Posts: 34
Joined: 23 Aug 2016, 17:46

Invalid value passes error when sending float in SFSObject from server

Postby pratts » 02 May 2017, 12:53

Hello,
I am trying to update our SFS to version 2.13 with binary protocol.
I am sending a parameter from the server as float type:
sfsobj.putFloat("temp", temp);

By chance the value of temp in some cases is 0. In that case the new JS api with binary protocol support gives an error:
Uncaught Error: Invalid value passed; type SFSDataType.FLOAT requires a number in this range: 1.401298464324817e-45 <= value <= 3.4028234663852886e+38
at SFSTypeError.SFSError (sfs2x-api-1.7.0.js:formatted:2956)
at new SFSTypeError (sfs2x-api-1.7.0.js:formatted:2984)
at Object.validate (sfs2x-api-1.7.0.js:formatted:3404)
at SFSObject.put (sfs2x-api-1.7.0.js:formatted:3583)
at SFSDataSerializer.decodeSFSObject (sfs2x-api-1.7.0.js:formatted:2468)
at SFSDataSerializer.decodeObject (sfs2x-api-1.7.0.js:formatted:2547)
at SFSDataSerializer.decodeSFSObject (sfs2x-api-1.7.0.js:formatted:2466)
at SFSDataSerializer.decodeObject (sfs2x-api-1.7.0.js:formatted:2547)
at SFSDataSerializer.decodeSFSObject (sfs2x-api-1.7.0.js:formatted:2466)
at SFSDataSerializer.binary2object (sfs2x-api-1.7.0.js:formatted:2440)

On investigating further, I saw a condition failing:

Code: Select all

typeof value === "number" && value >= 1.401298464324817e-45 && value <= 3.4028234663852886e38

Here, the second condition :

Code: Select all

value >= 1.401298464324817e-45 && value <= 3.4028234663852886e38

is false when the variable value is 0.

I want to know a few more things:
- when you will be releasing the new C# api with binary protocol support ?
- can you tell a little difference between json based protocol and binary protocol in terms of SFS(or in general), how C# is json based ?

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

Re: Invalid value passes error when sending float in SFSObject from server

Postby Lapo » 03 May 2017, 07:19

Thanks for reporting.
We're working on a fix which should be out very soon. I'll post an update when it's ready.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
pratts
Posts: 34
Joined: 23 Aug 2016, 17:46

Re: Invalid value passes error when sending float in SFSObject from server

Postby pratts » 03 May 2017, 07:35

I want to know a few more things:
- when will you be releasing the new C# api with binary protocol support ?
- can you tell a little difference between json based protocol and binary protocol in terms of SFS(or in general), how C# is json based ?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Invalid value passes error when sending float in SFSObject from server

Postby Lapo » 03 May 2017, 08:47

pratts wrote:- when will you be releasing the new C# api with binary protocol support ?

We don't have a date yet, sorry. I think it could be out in June but I can't promise as of now. We'll keep you updated.

- can you tell a little difference between json based protocol and binary protocol in terms of SFS(or in general), how C# is json based ?

The SFS2X protocol can be transported in multiple ways, among which there are JSON and binary. The binary version is a bit more efficient and faster. In Unity the protocol switches to JSON only for WebGL exports, otherwise it uses the standard SFS2X binary protocol.

You can read more here:
http://docs2x.smartfoxserver.com/Overvi ... x-protocol

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 51 guests