Introduction and use of EasyProtocol

original
2015/04/11 19:11
Reading amount 1.6K

EasyProtocol is a serialization tool that currently provides support for java and c #. Because it is a binary format, it is much faster than using json and xml for data exchange. Of course, compared with a professional serialization tool such as protocol buffer, it may be inferior in performance and size, but it is lightweight, simple, suitable for learning from each other, and suitable for some small projects.

Package structure:

2 folders under the root directory: language and tools
 1. language: support java and c # languages respectively, and provide dependent jar packages and dll files 2. tools: Protocol generation tool Progen.bat -- Execute batch processing of generated class files EasyProtocol tools. jar -- the only jar package required to generate class files Config.xml -- Generate the relevant configuration of the class file. For specific configuration items, refer to the notes in the document Progen.xml -- protocol document summary file Protocols -- store the protocols we wrote manually

Description of protocol format:
The protocol and bean are defined by an xml file. The format of this protocol document is:
 <protocols> <Import file=""/> <Namespace name=""> <Bean name=""> <variable name=""  type=""/>  ... </Bean> ... </Namespace> <Namespace name=""> <Protocol name="" type="" maxsize=""> <variable name="" type=""/> ... </Protocol> ... </Namespace> </protocols>

The entire agreement document consists of Import and two Namespace elements:

element explain Attribute Introduction
Import
It is used to import other protocol documents, usually for public use
File: path of import file
Namespace
Namespace, including bean element and protocol element
Name: Namespace of bean and protocol
Bean

Define an entity bean to facilitate calling in Protocol,
Can contain multiple variable sub elements

Name: Name
Protocol
Define a protocol that can contain multiple variable sub elements
Name: Protocol Name
Type: Agreement No
Maxsize: protocol size
variable
Define a variable
Name: Variable Name

Type: variable type
Supported types: int, byte, boolean, short,
float,double,long,string,map,set,list,vector,array

        remarks:   For details, please refer to the attached instance protocols folder, which contains a common.xml public module protocol document and a module_11_player.xml player module protocol document

Github link : https://github.com/ksfzhaohui/easyProtocol
Download address: http://www.oschina.net/code/snippet_159239_47065

Expand to read the full text
Loading
Click to join the discussion 🔥 (1) Post and join the discussion 🔥
one comment
two Collection
zero fabulous
 Back to top
Top