Houdini 19.0 hwebserver

hwebserver.WebSocket class

Base class for WebSocket support with the embedded server.

On this page

This class is the base class for all websocket support in Houdini’s embedded server.

Note

WebSocket support is Python3 only.

Setup

On its own the WebSocket class cannot do much of anything. The class must be registered with the server so that incoming Upgrade: websocket requests can create an instance of the class and hand off the handling to the websocket instance. To install the instance the decorator can be used to install the websocket.

Example

The below example will echo back anything sent from the client. This websocket will be used anytime a client sends a HTTP upgrade request on path /echo.

@webSocket("/echo")
class WebSocketEcho(hwebserver.WebSocket):
    async def connect(self):
        await self.accept()

    async def receive(self, message):
        await self.send(message)

Methods

See also

hwebserver

クラス

開始と停止

ウェブリクエストの処理とレスポンスの返し

ウェブソケット

  • WebSocket

    Base class for WebSocket support with the embedded server.

  • hwebserver.webSocket

    Decorator for registering WebSocket classes with Houdini’s web server.

APIコール

  • hwebserver.apiFunction

    Decorator for functions that can be called through an API endpoint on Houdini’s web server, returning JSON or binary responses.

  • hwebserver.APIError

    Raise this exception in apiFunction handlers to indicate an error.