Binary Protocol
From EsWiki
Binary protocol reads and writes directly from a ByteArray utilizing all appropriate data types. This means:
- Lowest impact messaging possible in Flash. Smallest message sizes with shorter parsing times.
- The ability to send/receive binary data. You can send screen data as a private message from one user to another, or to the server to be saved, or...[insert idea here].
- Unique security ideas to be unveiled in a future release of ElectroServer.
To use the new binary protocol you need to have the ActionScript 3 client-side API. It won't work with ActionScript 2 because ActionScript 2 doesn't support binary socket or ByteArrays.
To enable the binary protocol in a Flash client you do the following:
- Import this: com.electrotank.electroserver4.entities.Protocol
- Add this line of code before creating a connection: es.setProtocol(Protocol.BINARY);
- You'll also need to add a new gateway listener for binary, or modify the existing text listener for binary. See Gateway Listener for details. Restart ES4 to take effect.
That's it! Nothing else changes. But now you can use the setByte/getByte and setByteArray/getByteArray methods of the EsObject in very interesting and useful ways.
