55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
#nullable enable
|
|
|
|
using System;
|
|
|
|
namespace ShrinkNetwork
|
|
{
|
|
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
|
|
public sealed class ShrinkNetworkMessageAttribute : Attribute
|
|
{
|
|
public int Opcode { get; }
|
|
public string? Route { get; }
|
|
|
|
public ShrinkNetworkMessageAttribute(int opcode, string? route = null)
|
|
{
|
|
Opcode = opcode;
|
|
Route = string.IsNullOrWhiteSpace(route) ? null : route.Trim();
|
|
}
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
|
|
public sealed class ShrinkNetworkSubscriberAttribute : Attribute
|
|
{
|
|
}
|
|
|
|
public enum ShrinkNetworkStateSyncRole
|
|
{
|
|
JoinRequest = 0,
|
|
JoinResponse = 1,
|
|
Command = 2,
|
|
StateDelta = 3,
|
|
LeaveNotice = 4,
|
|
Heartbeat = 5
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
|
|
public sealed class ShrinkNetworkStateSyncAttribute : Attribute
|
|
{
|
|
public string Group { get; }
|
|
public ShrinkNetworkStateSyncRole Role { get; }
|
|
|
|
public ShrinkNetworkStateSyncAttribute(string group, ShrinkNetworkStateSyncRole role)
|
|
{
|
|
Group = string.IsNullOrWhiteSpace(group) ? string.Empty : group.Trim();
|
|
Role = role;
|
|
}
|
|
}
|
|
|
|
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
|
|
public sealed class ShrinkNetworkSubscribeAttribute : Attribute
|
|
{
|
|
public ShrinkNetworkAuthority Authority { get; set; } = ShrinkNetworkAuthority.Any;
|
|
public string? Permission { get; set; }
|
|
}
|
|
}
|