Added NULL response
This commit is contained in:
parent
1f28c7cbba
commit
9af8f7d3d6
2 changed files with 6 additions and 2 deletions
|
@ -18,11 +18,12 @@ You can send raw text to the WS server. This text is in form of commands:
|
|||
- `MSG {token} {message}` will set the message and broadcast it to all logged-in clients;
|
||||
- `CLEAR {token}` will clear the current message.
|
||||
|
||||
You may receive one of two packets while using the server:
|
||||
You may receive one of three responses while using the server:
|
||||
|
||||
- `MSG {message}` to indicate there's a new message. The client should react by showing an alert with the message. If no message is present, the packet will be `MSG` only. In this case, the client shouldn't react.
|
||||
- `OK` indicates the action was successful. The client should react by showing an alert telling the user so.
|
||||
- `NULL` to indicate that no data is available. No client reaction is intended.
|
||||
|
||||
## Frontend
|
||||
|
||||
The frontend is a static HTML page and can be hosted on anything.
|
||||
The frontend is a static HTML page and can be hosted on anything.
|
||||
|
|
3
main.py
3
main.py
|
@ -18,6 +18,9 @@ async def handle(websocket):
|
|||
CONNECTIONS.add(websocket)
|
||||
async for message in websocket:
|
||||
if message == "GET":
|
||||
if EAS_MESSAGE == "":
|
||||
await websocket.send("NULL")
|
||||
return
|
||||
await websocket.send(f"MSG {EAS_MESSAGE}")
|
||||
if message.startswith(f"MSG {TOKEN} "):
|
||||
# broadcast from vee
|
||||
|
|
Reference in a new issue