use local function

This commit is contained in:
vis2k 2021-05-13 12:06:00 +08:00
parent a66fefb1e3
commit b7a6932b93

View File

@ -329,8 +329,8 @@ public static void RegisterHandler<T>(Action<T> handler, bool requireAuthenticat
// we use the same WrapHandler function for server and client. // we use the same WrapHandler function for server and client.
// so let's wrap it to ignore the NetworkConnection parameter. // so let's wrap it to ignore the NetworkConnection parameter.
// it's not needed on client. it's always NetworkClient.connection. // it's not needed on client. it's always NetworkClient.connection.
Action<NetworkConnection, T> handlerWrapped = (_, value) => { handler(value); }; void HandlerWrapped(NetworkConnection _, T value) => handler(value);
handlers[msgType] = MessagePacking.WrapHandler(handlerWrapped, requireAuthentication); handlers[msgType] = MessagePacking.WrapHandler((Action<NetworkConnection, T>) HandlerWrapped, requireAuthentication);
} }
/// <summary>Replace a handler for a particular message type. Should require authentication by default.</summary> /// <summary>Replace a handler for a particular message type. Should require authentication by default.</summary>