aiocoap.util.pyodide_websockets module

This module provides a slimmed-down replacement of the websockets module (that regularly powers aiocoap.transports.ws) – but implemented through pyodide’s JavaScript adapter towards the WebSocket module of the hosting browser. It aims to be a drop-in replacement that provides the parts that can be implemented in the browser, and to provide practical errors on the used entry points. It will not go out of its way to mimick every aspect of the websockets module, but restrain itself to what .ws needs.

Future developement: The module can probably be extended to cover all the implementable functionality of websockets, and provide meaningful errors on all its items. When that happens, it should be split out of aiocoap.

class aiocoap.util.pyodide_websockets.WebSocketCommonProtocol

Bases: object

class aiocoap.util.pyodide_websockets.WebSocketClientProtocol(socket)

Bases: WebSocketCommonProtocol

async recv()
async send(msg)
local_address = ('localhost', None)
on_message(event)
on_error(event)
on_close(event)
async aiocoap.util.pyodide_websockets.connect(uri, subprotocols=None, ping_interval=20, ssl=None) WebSocketClientProtocol
class aiocoap.util.pyodide_websockets.exceptions

Bases: object

A class that is a good-enough approximation of websockets.exceptions to get away with a single file implementing pyodide_websockets.

exception WebSocketException

Bases: Exception

exception ConnectionClosed

Bases: WebSocketException

class aiocoap.util.pyodide_websockets.WebSocketServerProtocol(*args, **kwargs)

Bases: object

aiocoap.util.pyodide_websockets.WebSocketServer

alias of WebSocketServerProtocol

aiocoap.util.pyodide_websockets.serve(*args, **kwargs)