Protobuf officially supports C ++ Java and python, and others are supported by third parties. Two official as3 versions are recommended:
- Action Script:
Http://code.google.com/p/protobuf-actionscript3/
- Action Script:
Https://code.google.com/p/protoc-gen-as3/
We are very grateful to the two authors for their contributions and expressed their feelings for improvement.
The first one submitted earlier is not updated for a long time. It is basically unavailable, and enum/extension is not supported. We mainly look at the project of the second link.
Protoc-gen-as3 is doing very well in general, unfortunately there are some shortcomings.
1. Dynamic is added before each class
This is sometimes disgusting. For example, if a developer changes the name of a field in proto and uses the old name in the program, compilation will not report errors. The ideal situation is that the field name of the Protocol has changed and an error must be reported during compilation.
We can use the SED tool to shave this dynamic out.
2. serialization and deserialization method parameters are insufficient.
For example, there is no method similar to the following to specify the serialization length.
writeTo(bytes:BytesArray, len:int):void
There is a similar problem during deserialization. No one specifies the length of the input data.
3. The message length is not obtained.
The simplest message package format is generally defined as: total_len + protobuf_msg
The write code is similar to this:
Sock. writeunsignedint (totallen); // write the total length protobufmsg. writeto (sock); // write the MSG to the output of the socket
But you cannot write code like above, because you cannot get the length of protobufmsg! In this way, only protobufmsg can be serialized to a bytesarray and the total length can be obtained. In this way, there is an additional process for writing data to bytesarray.
4. No clear () for the entire message ()
Here we mainly want to create a new msgbody object and use it repeatedly. But there is no clear () and there is no way to reuse it. You must constantly delete & New.