Bluebugs / freebox-elixir

Automatically exported from code.google.com/p/freebox-elixir
0 stars 0 forks source link

[Feature request] Ease the manipulation of binary network messages #12

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Using the ecore_con bindings, we can only use String objects to
send/receive data to/from the network. For textual network protocols, I
guess it's enough, but for those that use binary messages I don't find it
very handy to use String objects, because the scripts have to play with the
charCodeAt() and fromCharCode() methods in order to extract/add every
single byte from/to the message. So maybe it would be more convenient to be
able to send and receive messages using arrays of integers. I don't really
know how arrays are implemented in SM, and I'm pretty sure using them will
imply more validations on the Elixir side (to make sure the given array
isn't associative, contains only integers, etc.), but I'm sure it will
significantly ease the use of non-textual network protocols in Elixir scripts.

Here are possible implementations:
 - the connection is either in textual or binary mode (switchable using a
new method ecore_con_[server|client|url?]_mode_set()). In textual mode
(default), String objects are used for the network messages as usual. In
binary mode, the 'data' property of the
ELIXIR_CON_EVENT_[SERVER|CLIENT]_DATA events isn't a String object anymore,
but an array of integers, and the ecore_con_[server|client]_send() methods
take an array of integers as their second argument.
 - both String objects and integers arrays can be received and sent. The
'data' property of the ELIXIR_CON_EVENT_[SERVER|CLIENT]_DATA events is the
String representation of the network message, and a new 'bin_data' property
is added to the events which contains the message data as an array of
integers. The ecore_con_[server|client]_send() methods can take both String
objects and integers arrays as their second argument, and it's up to the
method implementations to behave differently based on the type of their
arguments.

PS: should we speak French or English here ? I guess both languages are
allowed, but which one is preferred ?

Original issue reported on code.google.com by Poor.NewBie@gmail.com on 27 May 2010 at 12:48

GoogleCodeExporter commented 9 years ago
I see some way to do that, but a quick metric give me for a 1500 bytes packet 
something around 10K for the associated JavaScript array and it's over head. 
Things will grow quickly.

So I need to understand why you need this kind of feature ?

If it's for reducing load on server or simplifying server code, look at 
Eet_Connection.

Original comment by moa.blue...@gmail.com on 9 Jun 2010 at 2:10

GoogleCodeExporter commented 9 years ago
My first concern was about performances, as I guess accessing an element from a 
(non-associative) array is quicker than extracting a character code from a 
string (especially if strings are encoded internally with something else than 
Unicode). Now that I've started working on my Elixir projects for a few weeks, 
I realize that my games won't use the network connections intensively, so it 
will probably not be a problem for me. But maybe it will be worth for other 
developers to be able to choose to use (much) more memory to store the network 
messages if it improves their games performances ?

Also, with C syntax languages, it's more intuitive to access elements of a 
buffer using brackets than using characters manipulations methods. But as 
developers will probably build there own wrappers around those methods in order 
to extract 8-bits, 16-bits and 32-bits words anyway, that point is probably not 
a big issue.

Original comment by Poor.NewBie@gmail.com on 12 Jun 2010 at 10:37