… | |
… | |
19 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | --> |
20 | --> |
21 | </head> |
21 | </head> |
22 | <body> |
22 | <body> |
23 | |
23 | |
|
|
24 | <h1>$Revision: 1.9 $</h1> |
|
|
25 | |
24 | <h1>KGS Protocol Description</h1> |
26 | <h1>KGS Protocol Description</h1> |
25 | |
27 | |
26 | <p>This XML document describes the KGS protocol. It is also used |
28 | <p>This XML document describes the KGS protocol. It is also used |
27 | to automatically generate the perl parser for all the messages and |
29 | to automatically generate the perl parser for all the messages and |
28 | structures in the protocol. Adapting it to other languages should be |
30 | structures in the protocol. Adapting it to other languages should be |
29 | trivial.</p> |
31 | trivial.</p> |
|
|
32 | |
|
|
33 | <p> |
|
|
34 | <b>Please note that the author of KGS has told me that he will |
|
|
35 | change the protocol in response to my efforts. This does not |
|
|
36 | necessarily mean that he will change the protocol just to make it |
|
|
37 | difficult to reverse-engineer the protocol, but if this happens, |
|
|
38 | I might not have the resources the track them, if they are too |
|
|
39 | extensive. Anyway, he made it clear that no help whatsoever is to be |
|
|
40 | expected.</b> |
|
|
41 | </p> |
30 | |
42 | |
31 | <p>If you feel you need to update the visual appearance of this |
43 | <p>If you feel you need to update the visual appearance of this |
32 | document, feel free to look at <tt>doc/doc2html.xsl</tt> and improve |
44 | document, feel free to look at <tt>doc/doc2html.xsl</tt> and improve |
33 | it.</p> |
45 | it.</p> |
34 | |
46 | |
… | |
… | |
121 | </td> |
133 | </td> |
122 | </tr> |
134 | </tr> |
123 | </table> |
135 | </table> |
124 | |
136 | |
125 | <h2>Primitive types used in the protocol.</h2> |
137 | <h2>Primitive types used in the protocol.</h2> |
|
|
138 | |
|
|
139 | <p>Apart from the basic types, I need to define some extra types to |
|
|
140 | deal with fixed-point values (based on integer types) or fixed-length |
|
|
141 | strings (either 7-bit-ascii or more limited (<code>A</code>), or UCS-2 |
|
|
142 | based (<code>S</code>)).</p> |
126 | |
143 | |
127 | <h4>TYPE username</h4> |
144 | <h4>TYPE username</h4> |
128 | BASE TYPE: A<br /> |
145 | BASE TYPE: A<br /> |
129 | LENGTH: 12<br /> |
146 | LENGTH: 12<br /> |
130 | MULTIPLIER: <br /> |
147 | MULTIPLIER: <br /> |
… | |
… | |
212 | <th>DEFAULT</th> |
229 | <th>DEFAULT</th> |
213 | <th>DEC-GUARD</th> |
230 | <th>DEC-GUARD</th> |
214 | </tr> |
231 | </tr> |
215 | <tr> |
232 | <tr> |
216 | <td colspan="4"> |
233 | <td colspan="4"> |
|
|
234 | |
|
|
235 | Everywhere a user + flags is required, even used in some places |
|
|
236 | where only a username is required. I see no general rule on when a |
|
|
237 | complete user and when a partial user is required. |
|
|
238 | |
217 | </td> |
239 | </td> |
218 | </tr> |
240 | </tr> |
219 | <tr> |
241 | <tr> |
220 | <td>name</td> |
242 | <td>name</td> |
221 | <td>username</td> |
243 | <td>username</td> |
… | |
… | |
249 | <th>DEFAULT</th> |
271 | <th>DEFAULT</th> |
250 | <th>DEC-GUARD</th> |
272 | <th>DEC-GUARD</th> |
251 | </tr> |
273 | </tr> |
252 | <tr> |
274 | <tr> |
253 | <td colspan="4"> |
275 | <td colspan="4"> |
|
|
276 | |
|
|
277 | This structure is used for challanges as well as in the special |
|
|
278 | TREE "subprotocol". It tightly encodes the game parameters. |
|
|
279 | |
254 | </td> |
280 | </td> |
255 | </tr> |
281 | </tr> |
256 | <tr> |
282 | <tr> |
257 | <td>ruleset</td> |
283 | <td>ruleset</td> |
258 | <td>U8</td> |
284 | <td>U8</td> |
… | |
… | |
355 | <th>DEFAULT</th> |
381 | <th>DEFAULT</th> |
356 | <th>DEC-GUARD</th> |
382 | <th>DEC-GUARD</th> |
357 | </tr> |
383 | </tr> |
358 | <tr> |
384 | <tr> |
359 | <td colspan="4"> |
385 | <td colspan="4"> |
|
|
386 | |
|
|
387 | Send on the initial login. The password needs to be set when the |
|
|
388 | guest flag is true. |
|
|
389 | |
360 | </td> |
390 | </td> |
361 | </tr> |
391 | </tr> |
362 | <tr> |
392 | <tr> |
363 | <td>ver_major</td> |
393 | <td>ver_major</td> |
364 | <td>U32</td> |
394 | <td>U32</td> |
… | |
… | |
488 | <th>DEFAULT</th> |
518 | <th>DEFAULT</th> |
489 | <th>DEC-GUARD</th> |
519 | <th>DEC-GUARD</th> |
490 | </tr> |
520 | </tr> |
491 | <tr> |
521 | <tr> |
492 | <td colspan="4"> |
522 | <td colspan="4"> |
493 | Request a user picture from the server. |
523 | Request a user picture from the server. Results in a userpic-reply |
|
|
524 | or a timeout :/. |
494 | </td> |
525 | </td> |
495 | </tr> |
526 | </tr> |
496 | <tr> |
527 | <tr> |
497 | <td>name</td> |
528 | <td>name</td> |
498 | <td>username</td> |
529 | <td>username</td> |
… | |
… | |
578 | <th>DEFAULT</th> |
609 | <th>DEFAULT</th> |
579 | <th>DEC-GUARD</th> |
610 | <th>DEC-GUARD</th> |
580 | </tr> |
611 | </tr> |
581 | <tr> |
612 | <tr> |
582 | <td colspan="4"> |
613 | <td colspan="4"> |
583 | List the rooms in a specific group/category. |
614 | List the rooms in a specific group/category. Results in a upd_rooms message. |
584 | </td> |
615 | </td> |
585 | </tr> |
616 | </tr> |
586 | <tr> |
617 | <tr> |
587 | <td>group</td> |
618 | <td>group</td> |
588 | <td>U8</td> |
619 | <td>U8</td> |
… | |
… | |
719 | <th>DEFAULT</th> |
750 | <th>DEFAULT</th> |
720 | <th>DEC-GUARD</th> |
751 | <th>DEC-GUARD</th> |
721 | </tr> |
752 | </tr> |
722 | <tr> |
753 | <tr> |
723 | <td colspan="4"> |
754 | <td colspan="4"> |
|
|
755 | Joins the given room. join_room messages for yourself |
|
|
756 | and all users in that room, as well as the initial gamelist, are |
|
|
757 | send if the room exists. If not, timeout... |
724 | </td> |
758 | </td> |
725 | </tr> |
759 | </tr> |
726 | <tr> |
760 | <tr> |
727 | <td>channel</td> |
761 | <td>channel</td> |
728 | <td>U16</td> |
762 | <td>U16</td> |
… | |
… | |
755 | <th>DEFAULT</th> |
789 | <th>DEFAULT</th> |
756 | <th>DEC-GUARD</th> |
790 | <th>DEC-GUARD</th> |
757 | </tr> |
791 | </tr> |
758 | <tr> |
792 | <tr> |
759 | <td colspan="4"> |
793 | <td colspan="4"> |
|
|
794 | Send a message to the room. |
760 | </td> |
795 | </td> |
761 | </tr> |
796 | </tr> |
762 | <tr> |
797 | <tr> |
763 | <td>channel</td> |
798 | <td>channel</td> |
764 | <td>U16</td> |
799 | <td>U16</td> |
… | |
… | |
777 | <td> |
812 | <td> |
778 | <b></b> </td> |
813 | <b></b> </td> |
779 | </tr> |
814 | </tr> |
780 | <tr> |
815 | <tr> |
781 | <td colspan="4"> |
816 | <td colspan="4"> |
|
|
817 | Must be the login-name of the user. |
782 | </td> |
818 | </td> |
783 | </tr> |
819 | </tr> |
784 | <tr> |
820 | <tr> |
785 | <td>message</td> |
821 | <td>message</td> |
786 | <td>STRING</td> |
822 | <td>STRING</td> |
… | |
… | |
802 | <th>DEFAULT</th> |
838 | <th>DEFAULT</th> |
803 | <th>DEC-GUARD</th> |
839 | <th>DEC-GUARD</th> |
804 | </tr> |
840 | </tr> |
805 | <tr> |
841 | <tr> |
806 | <td colspan="4"> |
842 | <td colspan="4"> |
|
|
843 | Remove yourself (or maybe others as admin) from a room. |
807 | </td> |
844 | </td> |
808 | </tr> |
845 | </tr> |
809 | <tr> |
846 | <tr> |
810 | <td>channel</td> |
847 | <td>channel</td> |
811 | <td>U16</td> |
848 | <td>U16</td> |
… | |
… | |
838 | <th>DEFAULT</th> |
875 | <th>DEFAULT</th> |
839 | <th>DEC-GUARD</th> |
876 | <th>DEC-GUARD</th> |
840 | </tr> |
877 | </tr> |
841 | <tr> |
878 | <tr> |
842 | <td colspan="4"> |
879 | <td colspan="4"> |
|
|
880 | Unclear. |
843 | </td> |
881 | </td> |
844 | </tr> |
882 | </tr> |
845 | <tr> |
883 | <tr> |
846 | <td>channel</td> |
884 | <td>channel</td> |
847 | <td>U16</td> |
885 | <td>U16</td> |
… | |
… | |
907 | <th>DEFAULT</th> |
945 | <th>DEFAULT</th> |
908 | <th>DEC-GUARD</th> |
946 | <th>DEC-GUARD</th> |
909 | </tr> |
947 | </tr> |
910 | <tr> |
948 | <tr> |
911 | <td colspan="4"> |
949 | <td colspan="4"> |
912 | request to update room game list (send once per minute) |
950 | Request to update room game list (send this once per minute to get |
|
|
951 | updated). Results in upd_games messages. |
913 | </td> |
952 | </td> |
914 | </tr> |
953 | </tr> |
915 | <tr> |
954 | <tr> |
916 | <td>channel</td> |
955 | <td>channel</td> |
917 | <td>U16</td> |
956 | <td>U16</td> |
… | |
… | |
959 | <th>DEFAULT</th> |
998 | <th>DEFAULT</th> |
960 | <th>DEC-GUARD</th> |
999 | <th>DEC-GUARD</th> |
961 | </tr> |
1000 | </tr> |
962 | <tr> |
1001 | <tr> |
963 | <td colspan="4"> |
1002 | <td colspan="4"> |
964 | No idea. |
1003 | Unclear. |
965 | </td> |
1004 | </td> |
966 | </tr> |
1005 | </tr> |
967 | <tr> |
1006 | <tr> |
968 | <td>channel</td> |
1007 | <td>channel</td> |
969 | <td>U16</td> |
1008 | <td>U16</td> |
… | |
… | |
1008 | <th>DEFAULT</th> |
1047 | <th>DEFAULT</th> |
1009 | <th>DEC-GUARD</th> |
1048 | <th>DEC-GUARD</th> |
1010 | </tr> |
1049 | </tr> |
1011 | <tr> |
1050 | <tr> |
1012 | <td colspan="4"> |
1051 | <td colspan="4"> |
|
|
1052 | Join a game. See join_room. |
1013 | </td> |
1053 | </td> |
1014 | </tr> |
1054 | </tr> |
1015 | <tr> |
1055 | <tr> |
1016 | <td>channel</td> |
1056 | <td>channel</td> |
1017 | <td>U16</td> |
1057 | <td>U16</td> |
… | |
… | |
1044 | <th>DEFAULT</th> |
1084 | <th>DEFAULT</th> |
1045 | <th>DEC-GUARD</th> |
1085 | <th>DEC-GUARD</th> |
1046 | </tr> |
1086 | </tr> |
1047 | <tr> |
1087 | <tr> |
1048 | <td colspan="4"> |
1088 | <td colspan="4"> |
|
|
1089 | Leave (or kick as admin?) a certain user from a game. |
1049 | </td> |
1090 | </td> |
1050 | </tr> |
1091 | </tr> |
1051 | <tr> |
1092 | <tr> |
1052 | <td>channel</td> |
1093 | <td>channel</td> |
1053 | <td>U16</td> |
1094 | <td>U16</td> |
… | |
… | |
1080 | <th>DEFAULT</th> |
1121 | <th>DEFAULT</th> |
1081 | <th>DEC-GUARD</th> |
1122 | <th>DEC-GUARD</th> |
1082 | </tr> |
1123 | </tr> |
1083 | <tr> |
1124 | <tr> |
1084 | <td colspan="4"> |
1125 | <td colspan="4"> |
|
|
1126 | Upload a partial game tree to the server. This is used |
|
|
1127 | to send moves and even in-game comments to the server. For the comments, |
|
|
1128 | the server prepends the username and rank. |
1085 | </td> |
1129 | </td> |
1086 | </tr> |
1130 | </tr> |
1087 | <tr> |
1131 | <tr> |
1088 | <td>channel</td> |
1132 | <td>channel</td> |
1089 | <td>U16</td> |
1133 | <td>U16</td> |
… | |
… | |
1116 | <th>DEFAULT</th> |
1160 | <th>DEFAULT</th> |
1117 | <th>DEC-GUARD</th> |
1161 | <th>DEC-GUARD</th> |
1118 | </tr> |
1162 | </tr> |
1119 | <tr> |
1163 | <tr> |
1120 | <td colspan="4"> |
1164 | <td colspan="4"> |
|
|
1165 | Request the game tree starting at a given node. This is used |
|
|
1166 | when the server only sends a partial tree (with end code "more"). |
1121 | </td> |
1167 | </td> |
1122 | </tr> |
1168 | </tr> |
1123 | <tr> |
1169 | <tr> |
1124 | <td>channel</td> |
1170 | <td>channel</td> |
1125 | <td>U16</td> |
1171 | <td>U16</td> |
… | |
… | |
1152 | <th>DEFAULT</th> |
1198 | <th>DEFAULT</th> |
1153 | <th>DEC-GUARD</th> |
1199 | <th>DEC-GUARD</th> |
1154 | </tr> |
1200 | </tr> |
1155 | <tr> |
1201 | <tr> |
1156 | <td colspan="4"> |
1202 | <td colspan="4"> |
|
|
1203 | Unclear. |
1157 | </td> |
1204 | </td> |
1158 | </tr> |
1205 | </tr> |
1159 | <tr> |
1206 | <tr> |
1160 | <td>channel</td> |
1207 | <td>channel</td> |
1161 | <td>U16</td> |
1208 | <td>U16</td> |
… | |
… | |
1189 | <th>DEFAULT</th> |
1236 | <th>DEFAULT</th> |
1190 | <th>DEC-GUARD</th> |
1237 | <th>DEC-GUARD</th> |
1191 | </tr> |
1238 | </tr> |
1192 | <tr> |
1239 | <tr> |
1193 | <td colspan="4"> |
1240 | <td colspan="4"> |
|
|
1241 | Not checked. |
|
|
1242 | |
1194 | </td> |
1243 | </td> |
1195 | </tr> |
1244 | </tr> |
1196 | <tr> |
1245 | <tr> |
1197 | <td>channel</td> |
1246 | <td>channel</td> |
1198 | <td>U16</td> |
1247 | <td>U16</td> |
… | |
… | |
1236 | <th>DEFAULT</th> |
1285 | <th>DEFAULT</th> |
1237 | <th>DEC-GUARD</th> |
1286 | <th>DEC-GUARD</th> |
1238 | </tr> |
1287 | </tr> |
1239 | <tr> |
1288 | <tr> |
1240 | <td colspan="4"> |
1289 | <td colspan="4"> |
|
|
1290 | Can be send after a req_undo message was received to grant the undo. |
1241 | </td> |
1291 | </td> |
1242 | </tr> |
1292 | </tr> |
1243 | <tr> |
1293 | <tr> |
1244 | <td>channel</td> |
1294 | <td>channel</td> |
1245 | <td>U16</td> |
1295 | <td>U16</td> |
… | |
… | |
1261 | <th>DEFAULT</th> |
1311 | <th>DEFAULT</th> |
1262 | <th>DEC-GUARD</th> |
1312 | <th>DEC-GUARD</th> |
1263 | </tr> |
1313 | </tr> |
1264 | <tr> |
1314 | <tr> |
1265 | <td colspan="4"> |
1315 | <td colspan="4"> |
|
|
1316 | Resign the game. |
1266 | </td> |
1317 | </td> |
1267 | </tr> |
1318 | </tr> |
1268 | <tr> |
1319 | <tr> |
1269 | <td>channel</td> |
1320 | <td>channel</td> |
1270 | <td>U16</td> |
1321 | <td>U16</td> |
… | |
… | |
1297 | <th>DEFAULT</th> |
1348 | <th>DEFAULT</th> |
1298 | <th>DEC-GUARD</th> |
1349 | <th>DEC-GUARD</th> |
1299 | </tr> |
1350 | </tr> |
1300 | <tr> |
1351 | <tr> |
1301 | <td colspan="4"> |
1352 | <td colspan="4"> |
|
|
1353 | Change the teacher to somebody else (or possibly yourself == take it). |
1302 | </td> |
1354 | </td> |
1303 | </tr> |
1355 | </tr> |
1304 | <tr> |
1356 | <tr> |
1305 | <td>channel</td> |
1357 | <td>channel</td> |
1306 | <td>U16</td> |
1358 | <td>U16</td> |
… | |
… | |
1333 | <th>DEFAULT</th> |
1385 | <th>DEFAULT</th> |
1334 | <th>DEC-GUARD</th> |
1386 | <th>DEC-GUARD</th> |
1335 | </tr> |
1387 | </tr> |
1336 | <tr> |
1388 | <tr> |
1337 | <td colspan="4"> |
1389 | <td colspan="4"> |
|
|
1390 | Unclear. Maybe allow users to talk? No idea, really. |
|
|
1391 | |
1338 | </td> |
1392 | </td> |
1339 | </tr> |
1393 | </tr> |
1340 | <tr> |
1394 | <tr> |
1341 | <td>channel</td> |
1395 | <td>channel</td> |
1342 | <td>U16</td> |
1396 | <td>U16</td> |
… | |
… | |
1380 | <th>DEFAULT</th> |
1434 | <th>DEFAULT</th> |
1381 | <th>DEC-GUARD</th> |
1435 | <th>DEC-GUARD</th> |
1382 | </tr> |
1436 | </tr> |
1383 | <tr> |
1437 | <tr> |
1384 | <td colspan="4"> |
1438 | <td colspan="4"> |
|
|
1439 | Probably sets the "quiet" flag. Not checked. |
1385 | </td> |
1440 | </td> |
1386 | </tr> |
1441 | </tr> |
1387 | <tr> |
1442 | <tr> |
1388 | <td>channel</td> |
1443 | <td>channel</td> |
1389 | <td>U16</td> |
1444 | <td>U16</td> |
… | |
… | |
1416 | <th>DEFAULT</th> |
1471 | <th>DEFAULT</th> |
1417 | <th>DEC-GUARD</th> |
1472 | <th>DEC-GUARD</th> |
1418 | </tr> |
1473 | </tr> |
1419 | <tr> |
1474 | <tr> |
1420 | <td colspan="4"> |
1475 | <td colspan="4"> |
|
|
1476 | Reject a challenge from a given user. Not checked. |
|
|
1477 | |
1421 | </td> |
1478 | </td> |
1422 | </tr> |
1479 | </tr> |
1423 | <tr> |
1480 | <tr> |
1424 | <td>channel</td> |
1481 | <td>channel</td> |
1425 | <td>U16</td> |
1482 | <td>U16</td> |
… | |
… | |
1452 | <th>DEFAULT</th> |
1509 | <th>DEFAULT</th> |
1453 | <th>DEC-GUARD</th> |
1510 | <th>DEC-GUARD</th> |
1454 | </tr> |
1511 | </tr> |
1455 | <tr> |
1512 | <tr> |
1456 | <td colspan="4"> |
1513 | <td colspan="4"> |
|
|
1514 | I forgot. |
|
|
1515 | |
1457 | </td> |
1516 | </td> |
1458 | </tr> |
1517 | </tr> |
1459 | <tr> |
1518 | <tr> |
1460 | <td>channel</td> |
1519 | <td>channel</td> |
1461 | <td>U16</td> |
1520 | <td>U16</td> |
… | |
… | |
1479 | <th>DEFAULT</th> |
1538 | <th>DEFAULT</th> |
1480 | <th>DEC-GUARD</th> |
1539 | <th>DEC-GUARD</th> |
1481 | </tr> |
1540 | </tr> |
1482 | <tr> |
1541 | <tr> |
1483 | <td colspan="4"> |
1542 | <td colspan="4"> |
|
|
1543 | Send soon after log-in to set the defaults for game challenges. |
1484 | </td> |
1544 | </td> |
1485 | </tr> |
1545 | </tr> |
1486 | <tr> |
1546 | <tr> |
1487 | <td>gametype</td> |
1547 | <td>gametype</td> |
1488 | <td>U32</td> |
1548 | <td>U32</td> |
… | |
… | |
1582 | <th>DEFAULT</th> |
1642 | <th>DEFAULT</th> |
1583 | <th>DEC-GUARD</th> |
1643 | <th>DEC-GUARD</th> |
1584 | </tr> |
1644 | </tr> |
1585 | <tr> |
1645 | <tr> |
1586 | <td colspan="4"> |
1646 | <td colspan="4"> |
|
|
1647 | A challenge. |
|
|
1648 | |
1587 | </td> |
1649 | </td> |
1588 | </tr> |
1650 | </tr> |
1589 | <tr> |
1651 | <tr> |
1590 | <td>user1</td> |
1652 | <td>user1</td> |
1591 | <td>user</td> |
1653 | <td>user</td> |
… | |
… | |
1642 | <th>DEFAULT</th> |
1704 | <th>DEFAULT</th> |
1643 | <th>DEC-GUARD</th> |
1705 | <th>DEC-GUARD</th> |
1644 | </tr> |
1706 | </tr> |
1645 | <tr> |
1707 | <tr> |
1646 | <td colspan="4"> |
1708 | <td colspan="4"> |
|
|
1709 | Basic information about a game. Used in rooms for the gamelist and |
|
|
1710 | in games to detect when a game is saved, changed type (e.g. R => D) |
|
|
1711 | etc. |
|
|
1712 | |
1647 | </td> |
1713 | </td> |
1648 | </tr> |
1714 | </tr> |
1649 | <tr> |
1715 | <tr> |
1650 | <td>channel</td> |
1716 | <td>channel</td> |
1651 | <td>U16</td> |
1717 | <td>U16</td> |
… | |
… | |
1803 | <th>DEFAULT</th> |
1869 | <th>DEFAULT</th> |
1804 | <th>DEC-GUARD</th> |
1870 | <th>DEC-GUARD</th> |
1805 | </tr> |
1871 | </tr> |
1806 | <tr> |
1872 | <tr> |
1807 | <td colspan="4"> |
1873 | <td colspan="4"> |
|
|
1874 | Obsolete. |
|
|
1875 | |
1808 | </td> |
1876 | </td> |
1809 | </tr> |
1877 | </tr> |
1810 | <tr> |
1878 | <tr> |
1811 | <td>name</td> |
1879 | <td>name</td> |
1812 | <td>roomname</td> |
1880 | <td>roomname</td> |