Slight change to the proto
[tpg/opendispense2.git] / proto.txt
1 OpenDispense^2
2 Client/Server Dispense Protocol
3
4 The protocol is ASCII based, similar to the FTP protocol
5 All server responses are on one line and are prefixed by a three digit response code.
6
7 == Response Codes ==
8 100     Information
9 200     Command succeeded, no extra information
10 201     Command succeeded, array follows (<length> <items> <items> ...)
11 202     Command succeeded, per-command format
12 400     Unknown Command
13 401     Not Authenticated (or Authentication failure)
14 402     Balance insufficient
15 403     User not allowed to perform this action
16 404     Bad other username
17 406     Bad Item ID
18 500     Unknown Dispense Failure
19
20
21 === User Auth ===
22 c       USER <username>\n
23 s       100 SALT <string 4-8>\n
24 c       PASS <Hash>\n   (Hex-Encoded SHA-512 Hash of <username><salt><password>)
25 s       200 Auth OK\n or 401 Auth Failure\n
26 User is now authenticated
27
28 === Commands ===
29 --- Get Item list ---
30 c       ENUM_ITEMS\n
31 s       201 Items <count> <item_id> <item_id> ...\n
32 --- Get Item Information ---
33 c       ITEM_INFO <item_id>\n
34 s       202 Item <item_id> <price> "<description>"\n
35 --- Dispense an item ---
36 c       DISPENSE <item_id>\n
37 s       200 Dispense OK\n or 402 Poor You\n or 500 Dispense Error\n or 406 Bad Item\n
38 --- Give to another user ---
39 c       GIVE <user> <ammount> <reason>\n
40 s       200 Give OK\n or 402 Poor You\n or 404 Bad User\n
41 --- Update balance ---
42 c       ADD <user> <ammount> "<reason>"\n
43 s       200 Add OK\n or 403 Not Coke\n or 404 Bad User\n
44 --- Set Balance ---
45 c       SET <user> <balance> "<reason>"\n
46 s       200 Set OK\n or 403 Not allowed\n or 404 Bad User\n
47 --- Get Users Balances ---
48 c       ENUM_USERS[ <max balance>]\n
49 s       201 Users <count> <username> <username> ...\n
50 --- Get a User's Balance ---
51 c       USERINFO\n
52 s       202 User <username> <balance>\n

UCC git Repository :: git.ucc.asn.au