-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprotocol.txt
More file actions
72 lines (60 loc) · 1.69 KB
/
protocol.txt
File metadata and controls
72 lines (60 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Protocol for trading system
- Simple plain text messages are exchanged between client and server.
- Client sends requests for every action which the user does, and server responds to these.
Client messages (requests)
--------------------------
- Fields in the message are separated by newlines (\n)
- Messages are terminated by special character sequence $%*
- Common request format:
<trader-id>\n
<password>\n
<request-type>\n
<field1>\n
<field2>\n
.....\n
.....\n
$%*
- Login details are sent with every request, this way we don't have to implement sessions on the server. Just check them at every request and respond only if they are correct.
-Request Types Example
* Login request midhul\n
<trader-id>\n mypassword\n
<password>\n LOGIN\n
LOGIN\n $%*
$%*
* Buy request
<trader-id>\n
<password>\n
BUY\n
<item-code>\n
<qty>\n
<unit-price>\n
$%*
* Sell request
<trader-id>\n
<password>\n
SELL\n
<item-code>\n
<qty>\n
<unit-price>\n
$%*
* View orders
<trader-id>\n
<password>\n
VIEW_ORDERS\n
$%*
* View Trades
<trader-id>\n
<password>\n
VIEW_TRADES\n
$%*
Server Messages (responses)
---------------------------
- First lime should contain status (SUCCESS or FAIL)
- Following lines contain content which will be displayed as it is to the user by the client :P
- Common response format
<status>\n
<content>
- Responses should be given to each type of login request mentioned above
-Example response for login request:
SUCCESS\n
Successfully logged in!