README.txt 1.3 KB

12345678910111213141516171819202122232425
  1. Simple WebSocket client and server.
  2. Client
  3. ------
  4. The client can connect to a WebSocket server, and can send messages to it. Sent and received messages are logged in the browser window. Orthogonal to this sending and receiving of messages, is a heartbeat component that sends a 'ping' after the client has not sent any message (or ping) to the server for 1 second. When the client does not receive any message (or pong) from the server for 3 seconds, it decides that there is a timeout (server or network problem), and will stop sending pings until recovered.
  5. run_client.html: open this page in browser to run the WebSocket demo client
  6. client.xml: WebSocket client SCCD model. Compile with language=javascript and platform=eventloop.
  7. client.js: generated code from client.xml, imported by run_client.html
  8. Server
  9. ------
  10. The server is very simple. It creates a Connection object for every incoming connection, and destroys this object when the connection is closed. The Connection object listens for incoming messages. Every incoming message is responded to asap:
  11. - a 'ping' is responded to with a 'pong'
  12. - a 'msg' is echoed.
  13. Files:
  14. run_server.py: Python script to run the WebSocket demo server
  15. server.xml: WebSocket server SCCD model. Compile with language=python and platform=eventloop.
  16. server.py: generated code from server.xml, imported by run_server.py