ForcePilot/backend/package/yuxi/gateway/protocol/version.py
Kris fee71576a2 feat(gateway): add core gateway protocol implementation
新建了完整的网关协议模块,包含版本协商、基础类型定义、信道请求模型、错误码规范、通信帧结构以及握手流程,实现了完整的客户端-服务端通信协议基础框架
2026-05-12 00:54:15 +08:00

14 lines
326 B
Python

from __future__ import annotations
PROTOCOL_VERSION: int = 1
def negotiate_version(client_min: int, client_max: int) -> int | None:
server_max = PROTOCOL_VERSION
server_min = 1
negotiated = min(client_max, server_max)
if negotiated >= max(client_min, server_min):
return negotiated
return None