Note
The examples here demonstrate WebSocket programming with |ab| and are available in Twisted and asyncio-based variants respectively.
A simple WebSocket echo server and client.
This example shows a WebSocket server that will receive a JSON encode float over WebSocket, slowly compute the square, and send back the result. The example is intended to demonstrate how to use co-routines inside WebSocket handlers.
The example implements a testee for testing against Autobahn|Testsuite.
Note
The examples here demonstrate various further features and aspects of WebSocket programming with |ab|. However, these examples are currently only available for Twisted.
How to run WebSocket over TLS ("wss").
How to run WebSocket under Twisted Web. This is a very powerful feature, as it allows you to create a complete HTTP(S) resource hierarchy with different services like static file serving, REST and WebSocket combined under one server.
This example shows how to run Flask (or any other WSGI compliant Web thing) under Twisted Web and combine that with WebSocket.
A variant of the previous example that runs a HTTPS server with secure WebSocket on a subpath.
The example demonstrates how to trigger and process WebSocket pings and pongs.
- WebSocket Authentication with Mozilla Persona
- Broadcasting over WebSocket
- WebSocket Compression
- WebSocket over Twisted Endpoints
- Using HTTP Headers with WebSocket
- WebSocket on Multicore
- WebSocket as a Twisted Service
- WebSocket Echo Variants
- WebSocket Fallbacks
- Using multiple WebSocket Protocols
- Streaming WebSocket
- Wrapping Twisted Protocol/Factories over WebSocket
- Using wxPython with Autobahn