Here is a quick and dirty 1st cut at a wire protocol definition, and some
requirements for the message handling classes that will implement the
protocol
Preliminary FlightGear Server (FGS) wire protocol specification
0xFF Escape prefix for 0xF? bytes in the data
next byte is inverted, except for data type prefixes
0xFE Begin message, 8 bit message ID
0xFD Begin Message, 16 bit message ID
Code Type C/C++ equivalent
0xF0 byte unsigned char
0xF1 word unsigned int
0xF2 dword unsigned long
0xF3 qword unsigned long long
0xF4 signed byte char
0xF5 signed word int
0xF6 signed dword long
0xF7 signed qword long long
0xF8 32bit float float
0xF9 64bit double double
0xFA undefined
0xFB undefined
0xFC string, next byte is length char*
unterminated binary data
Unless there are objections, byte order is little endian, and floats are intel FPU
standard (ok -- i'm making it easy on the PCs that will likely be used to run display
clients :)
Messages are constructed by sending a Begin Message byte, followed by the message ID,
and then each data element.. clients/servers that dont understand a given message
should be able to skip past to the next start of message marker.
the FGSMessage base class will define an array of type/pointer that identifies the
type, and location to store each element of a message. Derived classes will load this
array with the correct associations for the specific message being sent or recieved.
Recieved messages must have the same types in the same order or the message is
rejected as invalid. All platform specific data conversion will happen in the
FGSMessage base class during packing/unpacking of the message.
Message objects derived from the FGSMessage base class will register with base class
using static methods to establish a factory style instantiation mechanism such that an
inbound message can be passed to a static method of FGSMessage, and the return value
will be a pointer to an object of the correct message type.
FGSMessage::recieve will be equally able to handle UDP packets with multiple messages,
or TCP packets with partial messages, buffering message fragments until the next time
the recieve method is called.
_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel