fix(signalr): encode enum by index

This commit is contained in:
MingxuanGame
2025-08-02 14:59:12 +00:00
parent a11ea743a7
commit 5ccb35dc8b
3 changed files with 27 additions and 19 deletions

View File

@@ -2,12 +2,14 @@ from __future__ import annotations
from abc import abstractmethod
import asyncio
from enum import Enum
import inspect
import time
from typing import Any
from app.config import settings
from app.log import logger
from app.models.signalr import UserState
from app.models.signalr import UserState, _by_index
from app.signalr.exception import InvokeException
from app.signalr.packet import (
ClosePacket,
@@ -265,6 +267,10 @@ class Hub[TState: UserState]:
continue
if issubclass(param.annotation, BaseModel):
call_params.append(param.annotation.model_validate(args.pop(0)))
elif inspect.isclass(param.annotation) and issubclass(
param.annotation, Enum
):
call_params.append(_by_index(args.pop(0), param.annotation))
else:
call_params.append(args.pop(0))
return await method_(client, *call_params)