Browse Source

Updated documentation

Yann Weber 2 years ago
parent
commit
4ec282ef37
2 changed files with 53 additions and 4 deletions
  1. 51
    2
      README.md
  2. 2
    2
      pyws_clock/__main__.py

+ 51
- 2
README.md View File

@@ -1,6 +1,6 @@
1
-# PyWSClock
1
+# pyws_clock
2 2
 
3
-Websocket clock server, handling timezones and alarms.
3
+Websocket clock server, handling timezones, alarms and sessions.
4 4
 
5 5
 ## Dependencies
6 6
 
@@ -86,3 +86,52 @@ systemctl status pyws_clock.service
86 86
 
87 87
 A sample configuration is available in `nginx_server.conf`.
88 88
 
89
+## Websocket server protocol description
90
+
91
+The server replies on any URL.
92
+
93
+Before entering the main loop, the listening server waits for 1st message
94
+containing a session ID. If an empty/dummy/invalid/unknown session ID is sent by the
95
+client, the server replies with a new, valid, session ID and enter the main loop.
96
+If a valid session ID is sent, the server reply the same session ID and enter
97
+the main loop, formated using `SESSION:<SESSION_ID>`.
98
+
99
+### Main loop
100
+
101
+The server send the current time (ISO 8601 format) every second.
102
+
103
+### Command results
104
+
105
+The client can interact with the server sending one of the command listed using
106
+`python3 -m pyws_clock -L`.
107
+
108
+When a client send a command, the next message from the server will be a command
109
+result. Results are string formatted using `<STATUS>:<DETAILS>.` Status can be
110
+one of `'ERR'` or `'OK'`, details are optionnale for OK statuses.
111
+
112
+### Alarms rings
113
+
114
+When an alarm is ringing, after sending time, the server send messages formatted
115
+using `ALRM:<NAME>` where `NAME `is the name of the ringing alarm.
116
+If multiple alarms are ringing, multiple `ALRM:` messages are sent every second.
117
+
118
+### Timezone informations
119
+
120
+Before the first time is sent and every time the timezone changes (inclucing
121
+summer/winter transitions), the clock. Timezones messages are formatted using
122
+`TZN:<TZNAME>`
123
+
124
+### Messages types summary
125
+
126
+* Session ID
127
+	* `SESSION:<SESSION_ID>`
128
+* Clock tick
129
+	* `ISO8601_Datetime`
130
+* Timezone name
131
+	* `TZN:<TZNAME>`
132
+* Alarm rings
133
+	* `ALRM:<JSON_ARRAY>`
134
+* Command results
135
+	* `OK:<DETAILS>`
136
+	* `ERR:<REASON>`
137
+

+ 2
- 2
pyws_clock/__main__.py View File

@@ -48,8 +48,8 @@ Alarms rings :
48 48
 --------------
49 49
 
50 50
 When an alarm is ringing, after sending time, the server send messages formatted
51
-using ALRM:<JSON_ARRAY> where JSON_ARRAY is a JSON array containing the name of
52
-the ringin alarms.
51
+using ALRM:<NAME> where NAME is the name of a ringing alarm. If multiple alarms
52
+are ringing, multiple ALRM: messages are sent every seconds.
53 53
 
54 54
 Timezone informations :
55 55
 -----------------------

Loading…
Cancel
Save