docs: Add user-friendly guide about how to use ws_server_example_test.py

This commit is contained in:
yuanjm
2022-01-13 10:50:38 +08:00
parent c6c7068776
commit 4bdcb9f5a9
2 changed files with 8 additions and 2 deletions

View File

@@ -6,7 +6,8 @@ This example demonstrates the HTTPD server using the WebSocket feature.
## How to Use Example
The example starts a WS server on a local network, so a WS client is needed to interact with the server (an example test
ws_server_example_test.py could be used as a simple WS client).
ws_server_example_test.py could be used as a simple WS client). If you run ws_server_example_test.py and get
`ModuleNotFoundError: No module named 'websocket'`, then please install `websocket` by running `python -m pip install websocket-client`.
The server registers WebSocket handler which echoes back the received WebSocket frame. It also demonstrates
use of asynchronous send, which is triggered on reception of a certain message.

View File

@@ -20,9 +20,14 @@ import os
import re
import ttfw_idf
import websocket
from tiny_test_fw import Utility
try:
import websocket
except ImportError:
print("Please install 'websocket' by running 'python -m pip install websocket-client'")
raise
OPCODE_TEXT = 0x1
OPCODE_BIN = 0x2
OPCODE_PING = 0x9