Three weeks ago we added support for WebSocket to our platform. WebSocket is a protocol providing full-duplex communications channels over a single TCP connection. It means that multiple clients can stay connected to a server and they can communicate back and forth much quicker than with the standard HTTP protocol.
One case where WebSocket is useful is when the changes made by one client need to be instantly broadcasted to the other clients.
As an example we’ve set up a shared drawing board web app where multiple people can draw on the same canvas at the same time. The tools we used are:
- A hosting account that supports WebSocket and Python
- The CherryPy Python web framework
- The WebSocket for Python library
- 300 lines of Python code for the web app itself
Here is a short video showing the drawing on one device being instantly displayed on another device (after travelling via the server which was hundreds of miles away):