Go to the latest version of this document.

# ``twisted`.`web`.`websocket`.`WebSocketResource``

class documentation

`class WebSocketResource(Resource): (source)`

Constructor: `WebSocketResource(factory)`

View In Hierarchy

A `WebSocketResource` is a `Resource` that presents a websocket listener. You can install it into any twisted web server resource hierarchy.

Method | `__init__` | Create a `WebSocketResource` that will respond to incoming connections with the given `WebSocketServerFactory`.
Method | `render_GET` | This implementation of the `GET` HTTP method will respond to inbound websocket connections.
Instance Variable | `factory` | Undocumented

Inherited from `Resource`:

Method | `delEntity` | Undocumented
Method | `getChild` | Retrieve a 'child' resource from me.
Method | `getChildForRequest` | Deprecated in favor of `getChildForRequest`.
Method | `getChildWithDefault` | Retrieve a static or dynamically generated child resource from me.
Method | `getDynamicEntity` | Undocumented
Method | `getStaticEntity` | Undocumented
Method | `listDynamicEntities` | Undocumented
Method | `listDynamicNames` | Undocumented
Method | `listEntities` | Undocumented
Method | `listNames` | Undocumented
Method | `listStaticEntities` | Undocumented
Method | `listStaticNames` | Undocumented
Method | `putChild` | Register a static child.
Method | `reallyPutEntity` | Undocumented
Method | `render` | Render a given resource. See `IResource`'s render method.
Method | `render_HEAD` | Default handling of HEAD method.
Class Variable | `allowedMethods` | Undocumented
Class Variable | `isLeaf` | Signal if this IResource implementor is a "leaf node" or not. If True, getChildWithDefault will not be called on this Resource.
Class Variable | `server` | Undocumented
Instance Variable | `children` | Undocumented

def __init__(self, factory: `WebSocketServerFactory[WebSocketProtocol]`): (source)
overrides `twisted.web.resource.Resource.__init__`

Create a `WebSocketResource` that will respond to incoming connections with the given `WebSocketServerFactory`.

Parameters
factory:`WebSocketServerFactory[WebSocketProtocol]` | The factory that will be used to respond to inbound websocket connections on appropriately formatted GET requests.

def render_GET(self, request: `Request`) -> `bytes | int`: (source)

This implementation of the `GET` HTTP method will respond to inbound websocket connections.

factory = (source)

Undocumented