Joeri Exelmans 15fa3e579b WebSocket demo: server goodbye message 5 年 前
..
.gitignore b281f38622 Added initial version of WebSocket server (SCCD w/ Python target, using 'websockets' library) 5 年 前
README.txt 4dcd6b11f4 WebSocket example: Add README 5 年 前
client.js 285d5ebd45 Begin modeling example WebSocket server in SCCD (w/ Python target) 5 年 前
client.xml 7b80aaf913 JS example: Cleaner implementation of WebSocket client 5 年 前
run_client.html 4dcd6b11f4 WebSocket example: Add README 5 年 前
run_server.py b281f38622 Added initial version of WebSocket server (SCCD w/ Python target, using 'websockets' library) 5 年 前
server.js c3f8fa0b47 JS example: WebSocket client 5 年 前
server.py 15fa3e579b WebSocket demo: server goodbye message 5 年 前
server.xml 15fa3e579b WebSocket demo: server goodbye message 5 年 前

README.txt

Simple WebSocket client and server.


Client
------

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.

run_client.html: open this page in browser to run the WebSocket demo client
client.xml: WebSocket client SCCD model. Compile with language=javascript and platform=eventloop.
client.js: generated code from client.xml, imported by run_client.html

Server
------

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:
- a 'ping' is responded to with a 'pong'
- a 'msg' is echoed.

Files:

run_server.py: Python script to run the WebSocket demo server
server.xml: WebSocket server SCCD model. Compile with language=python and platform=eventloop.
server.py: generated code from server.xml, imported by run_server.py