Project

General

Profile

Protocol Buffers » History » Version 1

Nevcairiel, 05/06/2010 02:54 PM

1 1 Nevcairiel
h1. Protocol Buffers
2 1 Nevcairiel
3 1 Nevcairiel
"Google Protocol Buffers":http://code.google.com/apis/protocolbuffers/ is an open binary serialization format created by Google.
4 1 Nevcairiel
This page describes an attempt to create an alternate language and platform neutral protocol for Quassel using the Protocol Buffers format.
5 1 Nevcairiel
6 1 Nevcairiel
h2. Why Protocol Buffers?
7 1 Nevcairiel
8 1 Nevcairiel
??
9 1 Nevcairiel
Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – *think XML, but smaller, faster, and simpler*
10 1 Nevcairiel
??
11 1 Nevcairiel
12 1 Nevcairiel
Protocol buffers are not just a format definition, but also include code generation for many different languages.
13 1 Nevcairiel
14 1 Nevcairiel
This offers several advantages, one being a absolutely clear defined, self-describing protocol, instead of protocol based on conventions and possibly outdated documentation.
15 1 Nevcairiel
Additionally, protocol buffers are a binary protocol, with highly optimized implementations in several languages. Official support by Google for C++, Java and Python, as well as third party extension for many other popular languages, including PHP, Obj-C, Perl, JS, and many more.
16 1 Nevcairiel
17 1 Nevcairiel
h2. Protocol definition
18 1 Nevcairiel
19 1 Nevcairiel
Note: The protocol is still being actively worked on.
20 1 Nevcairiel
The outlined protocol definitions are not final, and just listed here for documentation.
21 1 Nevcairiel
22 1 Nevcairiel
h3. Message Container
23 1 Nevcairiel
24 1 Nevcairiel
Every Message has to be wrapped in a container, since we otherwise can't determine the message type. This is done by the "QuasselServerMessage" and "QuasselClientMessage" message types. This design is modeled around the Protocol Buffers "Union Types":http://code.google.com/apis/protocolbuffers/docs/techniques.html#union example.
25 1 Nevcairiel
26 1 Nevcairiel
QuasselServerMessage are messages the server sends, while QuasselClientMessage are messages the client sends.
27 1 Nevcairiel
28 1 Nevcairiel
<pre>
29 1 Nevcairiel
message QuasselServerMessage {
30 1 Nevcairiel
  enum MessageType {
31 1 Nevcairiel
    ERROR = 0,         // Generic message for errors
32 1 Nevcairiel
    SUCCESS = 1,       // Generic message for success
33 1 Nevcairiel
    SESSION_STATE = 2, // State of current session, sent after init
34 1 Nevcairiel
    ...
35 1 Nevcairiel
  }
36 1 Nevcairiel
  required MessageType type = 1;
37 1 Nevcairiel
  
38 1 Nevcairiel
  optional ErrorMessage errorMessage = 100;
39 1 Nevcairiel
  optional SuccessMessage successMessage = 101;
40 1 Nevcairiel
  optional SessionState sessionState = 102;
41 1 Nevcairiel
  ...
42 1 Nevcairiel
}
43 1 Nevcairiel
</pre>
44 1 Nevcairiel
45 1 Nevcairiel
<pre>
46 1 Nevcairiel
message QuasselClientMessage {
47 1 Nevcairiel
  enum MessageType {
48 1 Nevcairiel
    REQUEST = 0,       // Generic Request message (request init, request login, request backlog, etc..)
49 1 Nevcairiel
    ...
50 1 Nevcairiel
  }
51 1 Nevcairiel
  required MessageType type = 1;
52 1 Nevcairiel
  
53 1 Nevcairiel
  optional RequestMessage request = 2;
54 1 Nevcairiel
  ...
55 1 Nevcairiel
}
56 1 Nevcairiel
</pre>
57 1 Nevcairiel
58 1 Nevcairiel
Once the protocol is better defined, the full protocol files will be available here.