-
Notifications
You must be signed in to change notification settings - Fork 3
Wff Binary Message
Wff binary message is a message format which can hold binary data. Unlike in bson/json, wff binary message is a collection of name-values pairs where both name and values can be binary data and it can also have duplicate names. It's implemented in com.webfirmframework.wffweb.util.WffBinaryMessageUtil
. The length of wff binary message is less than that of a JSON/BSON bytes, it's indeed valuable when a large amount of data needs to be processed / sent over network. And encoding and decoding of wff binary message is many times faster than JSON/BSON bytes. It is proved in com.webfirmframework.wffweb.util.WffBinaryMessageUtilTest
test case. We have a made a major improvement in the algorithm and its implementation, it is available since wffweb-1.1.5.
Since wffweb-2.x.x, wff binary message is used as an application protocol in server client bi-directional communication. It may be used to transfer data across networks and clients where fast delivery and processing is required.
- Unlike JSON, Wff Binary Message can hold raw binary data in name and values.
- Wff Binary Message size is lower than JSON bytes. Eg:- The minimal length of json string
{"name1":["value1","value2","value3","value4","value5","value6","value7","value8","value9","valu10"]}
is 101 but for the same data, wff message size is 79 bytes. - Wff Binary Message size is lower than BSON bytes. Eg:- The minimal length of BSON bytes for
{"name1":["value1","value2","value3","value4","value5","value6","value7","value8","value9","valu10"]}
is 157 but for the same data, wff message size is 79 bytes. - decoding and encoding is faster than JSON and BSON.
The message size is valuable when there are large number of messages or a large message to transfer across networks. This is one of the reasons why wffweb-2.x.x gives high performance for UI updates.
- The message data is not human readable as it's raw bytes so it will be less convenient for debug purpose.
- Each byte in wff binary message is tightly formed so any change in the wff binary message bytes could cause unexpected result while decoding.
The first byte represents the maximum number of bytes for name length bytes. The second byte represents the maximum number of bytes for the value length bytes. The remaining bytes represent the name-values pairs.
name length bytes | name bytes | values length bytes | values bytes |
---|
Here, the name length bytes is the length of name bytes and values length bytes is the length of values bytes.
The values bytes is an array of value bytes.
total values length bytes | value length bytes | value bytes | value length bytes | value bytes |
---|
Here, total values length bytes = sum of (value length bytes + value bytes + value length bytes + value bytes) no. of bytes. (we have removed extra identifier byte A from wff binary message version 1. Its implementation will be available since wffweb-1.1.5)
Code samples of com.webfirmframework.wffweb.util.WffBinaryMessageUtil
is given in this link.
We will soon implement wff binary message algorithm in other languages like javascript (it's implemented and available in 2.x.x version), objective-c etc... Or, if you want us to immediately implement this algorithm in any other languages, please create a ticket for it.
Refer wffweb-javadoc, Watch technical videos
Feel free to write us @ [email protected] for any assistance
or
[email protected] for any technical support.
webfirmframework.com since 2014