Skip to main content

websocket_session

Takes a coroutine func(session), and returns an ASGI application.

def websocket_session(
func: Callable[[WebSocket], Awaitable[None]]
) - > ASGIApp

Takes a coroutine func(session), and returns an ASGI application.

Parameters

NameTypeDescription
funcCallable[[WebSocket], Awaitable[None]]The asynchronous function (coroutine) that will be executed for each WebSocket session. This function receives a WebSocket object as its sole argument.

Returns

TypeDescription
ASGIAppAn ASGI application that can handle WebSocket connections.