ForcePilot/backend/package/yuxi/channel/transport/protocol.py
Kris bab30f2715
Some checks failed
Deploy VitePress site to Pages / build (push) Has been cancelled
Ruff Format Check / Ruff Format & Lint (push) Has been cancelled
Deploy VitePress site to Pages / Deploy (push) Has been cancelled
feat:0715
2026-07-15 12:30:58 +08:00

31 lines
699 B
Python

from __future__ import annotations
from collections.abc import Awaitable, Callable
from enum import StrEnum
from typing import Protocol, runtime_checkable
class TransportState(StrEnum):
DISCONNECTED = "disconnected"
CONNECTING = "connecting"
CONNECTED = "connected"
RECONNECTING = "reconnecting"
STOPPED = "stopped"
MessageHandler = Callable[[bytes], Awaitable[None]]
@runtime_checkable
class Transport(Protocol):
@property
def state(self) -> TransportState: ...
async def start(self) -> None: ...
async def stop(self) -> None: ...
def on_message(self, handler: MessageHandler) -> None: ...
async def send(self, data: bytes | str) -> None: ...