ForcePilot/backend/package/yuxi/gateway/protocol/version.py

14 lines
326 B
Python
Raw Normal View History

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