|
|
%!s(int64=2) %!d(string=hai) anos | |
|---|---|---|
| .. | ||
| web | %!s(int64=2) %!d(string=hai) anos | |
| Makefile | %!s(int64=2) %!d(string=hai) anos | |
| README.md | %!s(int64=2) %!d(string=hai) anos | |
| appweb.conf | %!s(int64=2) %!d(string=hai) anos | |
| echo.c | %!s(int64=2) %!d(string=hai) anos | |
| start.me | %!s(int64=2) %!d(string=hai) anos | |
This sample shows how to create a WebSockets echo server. This application echos incoming packets back to the client. The application source is in echo.c. This is a simple ESP controler with one action that is run in response to the URI:
/ws/test/echo
The HTML page web/index.html is served to the client browser to issue a web socket request.
The server is configured to keep the web socket open for 1 minute of inactivity and then close the connection.
make
make run
The server listens on port 8080. Browse to:
http://localhost:8080/
This opens a web socket and sends the message "Hello Server" to the server. The server responds by echoing back the message. After one minute of inactivity, the server will close the connection.