Sending byte arrays

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

Moderators: Lapo, Bax

sorencoder
Posts: 7
Joined: 19 Jan 2019, 15:53

Sending byte arrays

Postby sorencoder » 19 Jan 2019, 16:17

Hi,
We are using Protocol Buffers for serialization and sending messages. However I can't find a way to send raw byte arrays with SmartFoxServer.
SFSObject is terrible and error prone. I prefer to keep serialization automatic to avoid bugs.
How can I send raw byte array?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Sending byte arrays

Postby Lapo » 20 Jan 2019, 13:15

Hi,
SmartFoxServer 2X has uses its own codec/protocol serializer which cannot be bypassed. If you want to send raw bytes you can wrap them into an SFSObject via the put/getByteArray() methods
sorencoder wrote:SFSObject is terrible and error prone.

If you have specific bug reports regarding SFSObject let us know the details.
As regards the "terrible" qualifier, I have no idea how to respond to that :) It would probably help if you could at least explain the specific reason for your opinion and provide suggestions for improvements.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
sorencoder
Posts: 7
Joined: 19 Jan 2019, 15:53

Re: Sending byte arrays

Postby sorencoder » 20 Jan 2019, 15:08

First, Thank you for your response. I'll wrap byte arrays.

SFSObject problems:
First It's text-based. It means that we don't get intellisense or auto-completion. A simple typo in one of keys can lead to hard to catch bugs. We are using protobuf and it doesn't have this problem.
Second it's manual. You have to serialize and deserialize fields by hand. It's easy to forget to deserialize a newly added field in a complex class...
Third, Given that we use different languages for server and client, (Client is C# and Server is Java), We have to write Serialization and Deserialization twice! With previous two problems (being text-based and manual), It easily becomes a disaster.

Protobuf automatically generates model classes for both languages (Java and C#) and automatically serializes them. That's why we insist on using that.

It would be very helpful if you add support for 3rd-party serialization protocols.

Best Regards!
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Sending byte arrays

Postby Lapo » 21 Jan 2019, 08:39

It would be very helpful if you add support for 3rd-party serialization protocols.

As mentioned before, you can plug in your own custom binary serialization and wrap the raw data into a byte array.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: cvmouro and 103 guests