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 handler function that receives a WebSocket session instance and contains the logic for the connection.

Returns

TypeDescription
ASGIAppAn ASGI application that wraps the provided coroutine and manages the WebSocket lifecycle and exception handling.