Subversion Repositories ESP8266_P1_Meter

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 raymond 1
## AsyncFsWebServer – withWebSocket example
2
 
3
This folder contains a PlatformIO example and a small documentation set for the `AsyncFsWebServer` library.
4
 
5
### Documentation (available methods + usage)
6
 
7
- [docs/README.md](../../docs/README.md)
8
- [docs/API.md](../../docs/API.md)
9
- [docs/SetupAndWiFi.md](../../docs/SetupAndWiFi.md)
10
- [docs/FileEditorAndFS.md](../../docs/FileEditorAndFS.md)
11
- [docs/WebSocket.md](../../docs/WebSocket.md)
12
 
13
### Quick start (summary)
14
 
15
```cpp
16
AsyncFsWebServer server(80, FILESYSTEM, hostname);
17
 
18
if (FILESYSTEM.begin()) {
19
	server.printFileList(FILESYSTEM, "/", 1); // default -> Serial
20
}
21
 
22
if (!server.startWiFi(10000)) {
23
	server.startCaptivePortal("ESP_AP", "123456789", "/setup");
24
}
25
 
26
server.enableFsCodeEditor();
27
server.init(onWsEvent);
28
```
29
 
30
---
31
 
32
## Original note (example description)
33
This example is a bit more advanced than the [simpleServer](https://github.com/cotestatnt/esp-fs-webserver/tree/main/examples/simpleServer) example.
34
 
35
Basically, it uses the same HTML as simpleServer, but with the addition of a **WebSocket client** in the web page.
36
 
37
With WebSocket technology, we can send messages from server-to-client or client-to-server in a **full-duplex communication channel over a single TCP connection.**
38
 
39
In this simple example, it is used only to push a message from the ESP (the NTP-synchronized system time) to connected clients, just to show how to set up a system like this.
40
 
41
![image](https://user-images.githubusercontent.com/27758688/151001497-6468b50f-d4cb-46e1-ab4c-4d7aca3883db.png)