Well defined packet vs json ?

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

Moderators: Lapo, Bax

genar
Posts: 137
Joined: 13 Jul 2017, 11:49

Well defined packet vs json ?

Postby genar » 08 Mar 2021, 12:48

I actually need to serialize a bunch of my game classes to packets for sending them to the client. Therefore i have two ideas... i could either write some sort of GameClass->ISFSObject mapper or i could simply convert my game classes to json for inserting them into a packet.

Are there any advantages over using a well defined ISFSObject over a ISFSObject with a large json ?

Code: Select all

ISFSObject{
   name: "Lars",   ( String)
   positionX:"10", (Short)
   positionY:"10"   (Short)
}

vs

ISFSObject{
   data:"{name:'lars', positionX:'10', positionY:'10'}" ( String )
}
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Well defined packet vs json ?

Postby Lapo » 08 Mar 2021, 16:52

Hi,
the JSON version can be less efficient because it uses strings. At the same time the SFS2X protocol is compressed, so larger packets will benefit from that anyways.

My recommendations would be: if these JSON packets are sent very frequently I'd convert the relative data into native SFSObject, otherwise keep them as JSON, if it's more convenient.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 60 guests