Skip to content

WsLinkEndpoint

autogen.beta.network.transport.ws.WsLinkEndpoint #

WsLinkEndpoint(endpoint_id, ws)

Hub-side handle for one connected WebSocket client.

Constructed by :func:serve_ws on every incoming connection and passed to :meth:Hub.attach_endpoint. The hub's frame-processor task drives :meth:frames; outbound dispatch goes through :meth:send_frame. agent_id is populated by :meth:Hub.bind_endpoint after the client's :class:HelloFrame is validated.

Source code in autogen/beta/network/transport/ws.py
def __init__(self, endpoint_id: str, ws: "ServerConnection") -> None:
    # __init__ stores params; no side effects.
    self.endpoint_id = endpoint_id
    self.agent_id: str | None = None
    self._ws = ws
    self._closed = False

endpoint_id instance-attribute #

endpoint_id = endpoint_id

agent_id instance-attribute #

agent_id = None

send_frame async #

send_frame(frame)
Source code in autogen/beta/network/transport/ws.py
async def send_frame(self, frame: Frame) -> None:
    if self._closed:
        return
    try:
        await self._ws.send(json.dumps(encode_frame(frame)))
    except ConnectionClosed:
        return

frames #

frames()
Source code in autogen/beta/network/transport/ws.py
def frames(self) -> AsyncIterator[Frame]:
    return self._frames_impl()

close async #

close()
Source code in autogen/beta/network/transport/ws.py
async def close(self) -> None:
    if self._closed:
        return
    self._closed = True
    with contextlib.suppress(Exception):
        await self._ws.close()