Receiving Data - Some advice needed

Monkey Forums/Monkey Programming/Receiving Data - Some advice needed

Rushino(Posted 2013) [#1]
Hello!

My monkey will receive data from a server. This data come in some datastructure that contain an OpCode, Token and JSON but in string representation when the data arrive.

So i have to transform this data into a workable DataObject this involve create an object from the json using (damian.sinclair module), and add the object in the dataobject list. (if its data coming from an async query) otherwise handle the request immediatly (no token) like showing a message on screen.

The received data is based on an event. A method execute automatically when i get the data received from the server (probably in the next game loop)

Do you think a thread is needed to do theses kind of operation or its completly useless ? I mean.. i have 2 methods i could do. First put instantly the data receive into a list and handle this in the next game loop.. however this is useless (if i handle this now or later in the loop i will still have to handle this so this won't help me out) the other method would be to put the data in the list (untouched not transformed) and have a thread do the transformation and add then in the dataobject list or handle them immediatly. To me theses arent big operations. The game loop then (when it need some data) can check in the list cause the token is associated with an object data so i know where to find the data this way.

However, is this a bit overkill ? Do you think the transformation would make things way too slow ? or a thread should handle this ?

Note: Were not talking about binary transfer here.. this will involve probably a thread here for this.

Thanks!