From 9b0a4075f6940fab2d05530bab2ba3d7804cf85f Mon Sep 17 00:00:00 2001 From: rfi Date: Thu, 25 Apr 2024 11:47:15 +0700 Subject: [PATCH] try to fix protocol factory Invoke --- SCHALE.GameServer/Controllers/Api/GatewayController.cs | 2 +- .../Api/ProtocolHandlers/ProtocolHandlerFactory.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SCHALE.GameServer/Controllers/Api/GatewayController.cs b/SCHALE.GameServer/Controllers/Api/GatewayController.cs index 9f9684f..e9ee76a 100644 --- a/SCHALE.GameServer/Controllers/Api/GatewayController.cs +++ b/SCHALE.GameServer/Controllers/Api/GatewayController.cs @@ -59,7 +59,7 @@ namespace SCHALE.GameServer.Controllers.Api var payload = (JsonSerializer.Deserialize(payloadStr, requestType) as RequestPacket)!; - var rsp = protocolHandlerFactory.Invoke(protocol, [payload]); + var rsp = protocolHandlerFactory.Invoke(protocol, payload); if (rsp is null) { logger.LogDebug("{Protocol} {Payload:j}", payload.Protocol, payloadStr); diff --git a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/ProtocolHandlerFactory.cs b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/ProtocolHandlerFactory.cs index 42244df..073c58c 100644 --- a/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/ProtocolHandlerFactory.cs +++ b/SCHALE.GameServer/Controllers/Api/ProtocolHandlers/ProtocolHandlerFactory.cs @@ -18,7 +18,7 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers public interface IProtocolHandlerFactory { - public ResponsePacket? Invoke(Protocol protocol, params object?[]? args); + public ResponsePacket? Invoke(Protocol protocol, RequestPacket? req); public MethodInfo? GetProtocolHandler(Protocol protocol); public Type? GetRequestPacketTypeByProtocol(Protocol protocol); public void RegisterInstance(Type t, object? inst); @@ -62,14 +62,14 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers } } - public ResponsePacket? Invoke(Protocol protocol, params object?[]? args) + public ResponsePacket? Invoke(Protocol protocol, RequestPacket? req) { var handler = GetProtocolHandler(protocol); if (handler is null) return null; handlerInstances.TryGetValue(handler.DeclaringType!, out var inst); - return (ResponsePacket?)handler.Invoke(inst, args); + return (ResponsePacket?)handler.Invoke(inst, [req]); } public MethodInfo? GetProtocolHandler(Protocol protocol)