为所有函数和类添加中文注释文档字符串
This commit is contained in:
@@ -7,6 +7,7 @@ from aiortc import RTCIceCandidate
|
||||
|
||||
|
||||
def parse_ice(data: dict[str, Any]) -> RTCIceCandidate | None:
|
||||
"""解析ICE候选者字符串为RTCIceCandidate对象"""
|
||||
match = re.match(
|
||||
r'candidate:(\S+) (\d) (\S+) (\d+) (\S+) (\d+) typ (\S+)(?: raddr (\S+) rport (\d+))?',
|
||||
data["candidate"],
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class SignalingMessage:
|
||||
"""WebRTC信令消息数据模型"""
|
||||
type: str
|
||||
sdp: str = ""
|
||||
candidate: str = ""
|
||||
|
||||
@@ -11,6 +11,7 @@ from configs.load import config
|
||||
|
||||
|
||||
async def handle_client(websocket):
|
||||
"""处理单个WebSocket客户端连接"""
|
||||
client = websocket.remote_address
|
||||
logger.info(f"Client connected: {client}")
|
||||
|
||||
@@ -21,6 +22,7 @@ async def handle_client(websocket):
|
||||
|
||||
|
||||
async def main():
|
||||
"""启动WebSocket信令服务器"""
|
||||
cfg = config.server
|
||||
logger.info(f"WebRTC signaling server: ws://{cfg.host}:{cfg.port}")
|
||||
async with websockets.serve(handle_client, cfg.host, cfg.port, max_size=cfg.max_ws_size):
|
||||
|
||||
Reference in New Issue
Block a user