<msg version=`x.x'><msgType>...</msgType></msg>The version number `x.x' is necessary to meet the requirement of different versions of the server being able to co-exist seamlessly. The msgType tag is one of the ones described in tables 3.1, 3.2 and 3.3 and the msgType defines the format of the part of the message represented by ellipsis. If the message requires a signature (e.g. because it is updating some user information or is a message between users) then the message format becomes:
<msg version=`x.x'><msgType>...</msgType><signature>{sig}</signature></msg>
|
Table 3.4 describes the message format for each type of message. Words between curly braces({}) represents information to be inserted into the message.
The only message which has to encode really complex information is the serverlist message. It would be very easy to represent this information in a format such as: (where the ellipsis represent a data value to insert)
<server><hostname>...</hostname><port>...</port> <rtt><hostname>...</hostname><value>...</value></rtt> </server>
A serverlist would then consist of one of these
server strings for each server in the network. However, in
order to provide all this information, the parsing module would have
to pass back a tree structure to the calling program. This is quite an
overhead when the other message types can be represented in a simple
vector object (index
is the tagname,
is the text associated
with that tag). The message format described above continues to be
usable as it is possible to differentiate between servers by reading
the array sequentially. However, during development of the
server it was observed that it would be much more useful
if
random access to the elements of a message was possible. This meant
converting the MessageParser class to return an STL3.1multimap object. While this improved the efficiency of handling the
majority of message types, it rendered this format of the serverlist
message unusable as the elements could no longer be processed
sequentially. Therefore, a new encoding was chosen:
<h{IPAddr}>{port}</h{IPAddr}>
<r{srcIPAddr}_{destIPAddr}>{RTT value}</r{srcIPAddr}_{destIPAddr}>
The tag names begin with 'h' and 'r' because this was an efficient way of getting around XML not allowing tagnames to begin with a numeric character. For the hostname, the first character is discarded to obtain the IP address and for the RTT information, the tag name is linearly searched for an underscore character and then divided into the source IP address and the destination IP address.