Protocol Spec - 0xZ0F/RECourseCapstone GitHub Wiki
Please do not use this to cheat, this is mainly used so I don't forget the protocol spec as I develop the project.
The general control flow is as follows:
Client -- Hello -> Server
Client <-- SID --- Server
Client --- CMD --> Server
Client <-- ... --> Server
Client -- Exit --> Server
Every packet is prefixed with the header.
| DataLen | Type | Status | SID | Data |
|---|---|---|---|---|
| 2 Bytes | 1 Byte | 1 Byte | 4 Bytes |
DataLen Bytes |
-
DataLen- Length of the data. -
Type- Type of packet being sent. -
Status- Used to denote success or errors. -
SID- Session ID. Zero if one has not been provided. -
Data- Data for the type of packet sent.
No data.
| SID |
|---|
| 4 Bytes |
Check your balance.
| Flag |
|---|
| 1 Byte |
-
Flag- What format to receive the flag in. For example, pretty may be a string of$100.00and raw may be a float of100.00.
| Len | Data |
|---|---|
| 1 Byte |
Len Bytes |
-
Len- Length of the data. -
Data- Balance in the format specified byFlagin the request.
Get list of items for sale and information about them.
No data.
| ID | NameLen | DescLen | BuyPrice | SellPrice | Available | Name | Desc | ... |
|---|---|---|---|---|---|---|---|---|
| 2 Bytes | 1 Byte | 2 Bytes | 2 Bytes | 2 Bytes | 4 Bytes |
NameLen Bytes |
DescLen Bytes |
Next Item ... |
For the response, an item is defined as the following fields together:
-
ID- Item ID. -
NameLen- Length of the item's name. -
DescLen- Length of the item's description. -
BuyPrice- Cost to buy the item. -
SellPrice- Cost to sell the item. -
Available- Number of items in stock. -
Name- Item's name. -
Desc- Item's description.
Items are put sequentially one after another up to the length of DataLen in the header.
Search items for sale.
| Flag | QueryLen | Query |
|---|---|---|
| 1 Byte | 2 Bytes |
QueryLen Bytes |
-
Flag- Type of query such as search by name, description, etc. -
QueryLen- Length of theQuerystring. -
Query- Query string.
Same format as Store Inventory.
Get a list of items the client currently has.
No data.
| ID | NameLen | DescLen | Amount | Name | Desc | ... |
|---|---|---|---|---|---|---|
| 2 Bytes | 1 Byte | 2 Bytes | 4 Bytes |
NameLen Bytes |
DescLen Bytes |
Next Item ... |
-
ID- Item ID. -
NameLen- Length of the item's name. -
Name- Item's name. -
DescLen- Length of the item's description. -
Desc- Item's description. -
Amount- Number of this item owned.
Items are put sequentially one after another up to the length of DataLen in the header.
Buy an item from the store.
| ItemID |
|---|
| 2 Bytes |
-
ItemID- ID of the item to buy.
| Status |
|---|
| 1 Byte |
-
Status- Status of the buy such as success, failure, not in stock, etc.
It's recommended the client retrieves their balance again after a successful buy.
Sell an item if you have one.
| ItemID |
|---|
| 2 Bytes |
-
ItemID- ID of the item to sell.
| Status |
|---|
| 1 Byte |
-
Status- Status of the sell such as success, failure, etc.
It's recommended the client retrieves their balance again after a successful sell.