// This file is provided under The MIT License as part of RiptideNetworking.
// Copyright (c) Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub:
// https://github.com/RiptideNetworking/Riptide/blob/main/LICENSE.md
using System;
namespace Riptide
{
/// Specifies a method as the message handler for messages with the given ID.
///
///
/// In order for a method to qualify as a message handler, it must match a valid message handler method signature. s
/// will only use methods marked with this attribute if they match the signature, and s
/// will only use methods marked with this attribute if they match the signature.
///
///
/// Methods marked with this attribute which match neither of the valid message handler signatures will not be used by s
/// or s and will cause warnings at runtime.
///
///
/// If you want a or to only use a subset of all message handler methods, you can do so by setting up
/// custom message handler groups. Simply set the group ID in the constructor and pass the
/// same value to the or method. This
/// will make that or only use message handlers which have the same group ID.
///
///
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
public sealed class MessageHandlerAttribute : Attribute
{
/// The ID of the message type which this method is meant to handle.
public readonly ushort MessageId;
/// The ID of the group of message handlers which this method belongs to.
public readonly byte GroupId;
/// Initializes a new instance of the class with the and values.
/// The ID of the message type which this method is meant to handle.
/// The ID of the group of message handlers which this method belongs to.
///
/// s will only use this method if its signature matches the signature.
/// s will only use this method if its signature matches the signature.
/// This method will be ignored if its signature matches neither of the valid message handler signatures.
///
public MessageHandlerAttribute(ushort messageId, byte groupId = 0)
{
MessageId = messageId;
GroupId = groupId;
}
}
}