1
Message formats of libkdegames:
2
-------------------------------
4
There are two different communication layers, using their own protocols:
6
- the message layer (KMessageIO, KMessageServer, KMessageClient)
8
This is used to send messages from one client (i.e. KGame object)
9
to an other one, to a group of other clients, or to all the clients
10
connected to the KMessageServer. The messages are arbitrary blocks
11
of data, of an arbitrary length.
12
This layer is an underlying protocol that isn't game specific at all.
13
You shouldn't need to know the message format of the packets. If you
14
want to extend the protocol, have a look into KMessageServer API
15
reference for a complete list of message types.
17
- the game layer (KGame, KGameIO, KPlayer)
19
This layer uses the message layer to send its specific message packets
20
between the objects of the game.
21
This layer contains the game specific messages (e.g. addPlayer, setupGame).
22
The rest of this file describes this layer.
28
Application Cookie 16 Bit
35
The format of the messages is used internally and there is usually no reason why
36
you have to know what it is used for. But as usually != always here are some
37
comments on the format. Note that KGame is under development and the content of
38
this file could be obsolete. Please result the sourcecode for up-to-date
40
Application Cookie is used to identify the application. This prevents a
41
chess game from talking to a poker game.
42
Version is the version of KNetworkGame, sender and receiver must be of the same
44
library note: this could be a limitation, as KGame should be backward
45
compatible. Maybe change to version must be >= KNETWORKGAME or something less
47
MsgId specifies the kind of the message data (see below).
48
SenderId is the id of the KGame/KPlayer object which sent the message, it is
49
coded like this: the lower 10 bits specify a player and the upper bit
50
represent the game id shifted by 10 bits. So we get
51
Id=playerId | (gameId<<10);
52
ReceiverId is the id of the receiver of the message. It can be either
53
a player, a game or a broadcast. For a broadcast the Id is set to 0
54
in the other cases the coding is as with the senderId
55
Userdata is the data of the user (wow ;-))
59
---------------------------------------------------------
60
IdMessage user defined
62
IdSetupGame qint32 isServer
64
qint32 newid (id for the new game)
65
qint32 cntR (virtual player nunmber)
66
qint32 cntT (tagged player number)
71
IdSendPlayer qint32 omit how many tagged players for replacement
74
IdGameSave Save(msg)->Load(msg)
78
player->Save(msg) -> player->Load(msg)
80
IdRemovePlayer qint16 playerid
82
IdError qint32 errorcode
85
IdGameStatus qint32 status
87
IdPlayerProperty qint16 propertyId
88
user defined -> the property
90
IdGameProperty qint16 propertyId
91
user defined -> the property
93
IdPlayerInput user defined