Multiple Variables with one UDP message

BlitzMax Forums/BlitzMax Beginners Area/Multiple Variables with one UDP message

Don't you think that would cause a lot of extra overhead?
I made a little test.
On my system (Core2Duo 2.6 Ghz) it does around 5.000 serializings/deserializings per second.
The string of this small object gets a lenght of 245 bytes (can be packed within in the mod) which have to be sent. Yes, this can be called overhead :-)
But I like the idea to transfer complete objects.
For a game with a limited amount of data and players it could work nice.

SuperStrict
Import BaH.persistence ' the mod

Local t:TTimer = CreateTimer(100)

Local counter:Int
Local tosend:String
Repeat
	counter:+1
	Local pl:TPlayerData = New TPlayerData
	pl.x = 99'  set the values x,y etc.
	pl.y = 98
	pl.speed = 330000
	pl.direction = 1
	
	 tosend = TPersist.Serialize(pl) ' serialize playerdata to a string
	
	' now send string with UDP
	' .....
	' and at the client side deserialize it
	
	Local clientpd:TPlayerData = TPlayerData(TPersist.DeSerialize(tosend))
	PollEvent() ' for the timer
Until t.Ticks() = 100

Print "serializing/deserializing per sec.:" + counter
Print "length of string:" + tosend.Length
Print tosend

Type TPlayerData
	Field x:Int, y:Int
	Field speed:Int
	Field direction:Int
End Type