SFSObjectLite doesn't support ByteArray transmission.

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

ttienqb
Posts: 5
Joined: 24 May 2016, 08:39

SFSObjectLite doesn't support ByteArray transmission.

Postby ttienqb » 24 May 2016, 08:57

Hi
i have a bug.
SFSObjectLite doesn't support ByteArray transmission.
how to fix that bug?
thank in advance
p/s: my english bad. hope u understand. give me name account skype to i add skype and talk more :((
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby Lapo » 24 May 2016, 10:13

Hi,
SFSObjectLite is an alternative implementation of SFSObject used for websockets.
At the moment we don't support byte arrays in our websocket API, which is the reason of the error.

If you want to transmit byte data from an HTML application you can convert it to Base64 and send it as a String.

hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
ttienqb
Posts: 5
Joined: 24 May 2016, 08:39

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby ttienqb » 24 May 2016, 10:33

u can add my skype: thtienqb to talke more about help me :D
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby Lapo » 24 May 2016, 13:40

Explain your problem here.
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
ttienqb
Posts: 5
Joined: 24 May 2016, 08:39

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby ttienqb » 25 May 2016, 03:10

can u give example to convert SFSObjectLite to SFSObject
thank u :D
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby Lapo » 25 May 2016, 14:13

I don't understand what you're trying to do.
Normally you don't have to construct SFSObjectLite manually.

Can you give us a bit of context and explain what you're trying to do?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
foxboy
Posts: 110
Joined: 12 May 2011, 02:47
Location: Optimal Solution Pte. Ltd.

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby foxboy » 10 Sep 2016, 12:00

Hi Lapo,

We have the same issue with our project.

We have a mobile game (Unity Android/iOS) that uses ByteArrays heavily to send data to and from the server, we prefer that data type as it is more efficient especially if we are just sending integers whose values are less than 256. So we normally pack them together into a byte array and then deserialize it on either end.

Now, the problem is, we are planning to port the game to WebGL and release it on the Facebook platform. We have everything setup including WSS certificate. But when we tested the game (Unity WebGL), we got this error from the console:

NotSupportedException: SFSObjectLite doesn't support ByteArray transmission
Sfs2X.Entities.Data.SFSObjectLite.GetByteArray (System.String key)

And that is how I ended up to this thread looking for some answers.

Is there any plan on supporting ByteArrays for WebGL applications?
"Dream it, I'll code it..."
Lead Developer
Optimal Solution Pte. Ltd.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby Lapo » 10 Sep 2016, 19:19

Hi,
Is there any plan on supporting ByteArrays for WebGL applications?

yes there are plans, but not imminent as it will take a major rewrite of the API. At the time we started supporting websockets there was no support for byte arrays or byte manipulation in JS.

The rewrite is not going to affect developers though, it's more of a "behind the scenes" rewrite.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
foxboy
Posts: 110
Joined: 12 May 2011, 02:47
Location: Optimal Solution Pte. Ltd.

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby foxboy » 11 Sep 2016, 00:21

Thanks Lapo.

Do you have any estimated release date on when this can be available so we can decide if we are going to wait for it or just create a workaround solution?

Regarding the workaround, I want to know which is more efficient (in terms of bandwidth usage)

a) Create a SFSObject containing all the bytes in my ByteArray

soData.putByte("KEY", {each element of my ByteArray});
e.g.
soData.putByte("KEY0", MyByteArray[0]);
soData.putByte("KEY1", MyByteArray[1]);
soData.putByte("KEY2", MyByteArray[2]);
etc...

b) Create a SFSObject containing a Hex String equivalent of my ByteArray

e.g. MyByteArray = {255, 254, 253};

soData.putUtfString("KEY", "FF FE FD");
"Dream it, I'll code it..."
Lead Developer
Optimal Solution Pte. Ltd.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby Lapo » 12 Sep 2016, 07:18

Hi,
at this stage we don't have an estimated release date.

One workaround could be to detect if the client is websocket based and send him slightly different content, for example you could Base64 encode the same binary data you send to other clients.

Detecting a websocket client is simple:

Code: Select all

if (user.getSession().getType() == SessionType.WEBSOCKET)
{
   ...
}


Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
foxboy
Posts: 110
Joined: 12 May 2011, 02:47
Location: Optimal Solution Pte. Ltd.

Re: SFSObjectLite doesn't support ByteArray transmission.

Postby foxboy » 12 Sep 2016, 09:35

Ok Lapo,

Thanks for the info and suggestions, I will look into the Base64 workaround.
"Dream it, I'll code it..."
Lead Developer
Optimal Solution Pte. Ltd.

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 17 guests