hermes-common-library/Common/WebSocketHandlerTypeManager.cs
2024-06-24 22:28:40 +00:00

26 lines
879 B
C#

using CommonSocketLibrary.Abstract;
using CommonSocketLibrary.Common;
using Serilog;
namespace CommonSocketLibrary.Socket.Manager
{
public abstract class WebSocketHandlerTypeManager : HandlerTypeManager<WebSocketClient, IWebSocketHandler>
{
public WebSocketHandlerTypeManager(ILogger logger, HandlerManager<WebSocketClient, IWebSocketHandler> handlers) : base(logger, handlers)
{
}
protected override Type? FetchMessageType(Type handlerType)
{
if (handlerType == null)
return null;
var name = handlerType.Namespace + "." + handlerType.Name;
name = name.Replace(".Handlers.", ".Data.")
.Replace("Handler", "Message")
.Replace("MessageMessage", "Message");
return handlerType.Assembly.GetType(name);
}
}
}