try to fix protocol factory Invoke
This commit is contained in:
parent
5ca05509fc
commit
9b0a4075f6
|
@ -59,7 +59,7 @@ namespace SCHALE.GameServer.Controllers.Api
|
||||||
|
|
||||||
var payload = (JsonSerializer.Deserialize(payloadStr, requestType) as RequestPacket)!;
|
var payload = (JsonSerializer.Deserialize(payloadStr, requestType) as RequestPacket)!;
|
||||||
|
|
||||||
var rsp = protocolHandlerFactory.Invoke(protocol, [payload]);
|
var rsp = protocolHandlerFactory.Invoke(protocol, payload);
|
||||||
if (rsp is null)
|
if (rsp is null)
|
||||||
{
|
{
|
||||||
logger.LogDebug("{Protocol} {Payload:j}", payload.Protocol, payloadStr);
|
logger.LogDebug("{Protocol} {Payload:j}", payload.Protocol, payloadStr);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace SCHALE.GameServer.Controllers.Api.ProtocolHandlers
|
||||||
|
|
||||||
public interface IProtocolHandlerFactory
|
public interface IProtocolHandlerFactory
|
||||||
{
|
{
|
||||||
public ResponsePacket? Invoke(Protocol protocol, params object?[]? args);
|
public ResponsePacket? Invoke(Protocol protocol, RequestPacket? req);
|
||||||
public MethodInfo? GetProtocolHandler(Protocol protocol);
|
public MethodInfo? GetProtocolHandler(Protocol protocol);
|
||||||
public Type? GetRequestPacketTypeByProtocol(Protocol protocol);
|
public Type? GetRequestPacketTypeByProtocol(Protocol protocol);
|
||||||
public void RegisterInstance(Type t, object? inst);
|
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);
|
var handler = GetProtocolHandler(protocol);
|
||||||
if (handler is null)
|
if (handler is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
handlerInstances.TryGetValue(handler.DeclaringType!, out var inst);
|
handlerInstances.TryGetValue(handler.DeclaringType!, out var inst);
|
||||||
return (ResponsePacket?)handler.Invoke(inst, args);
|
return (ResponsePacket?)handler.Invoke(inst, [req]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodInfo? GetProtocolHandler(Protocol protocol)
|
public MethodInfo? GetProtocolHandler(Protocol protocol)
|
||||||
|
|
Loading…
Reference in New Issue