Files
HellionChat/HellionChat/Util/Payloads.cs
T
2026-05-11 08:11:30 +02:00

84 lines
2.5 KiB
C#
Executable File

using Dalamud.Game.Text.SeStringHandling;
namespace HellionChat.Util;
internal class PartyFinderPayload : Payload
{
public override PayloadType Type => (PayloadType)0x50;
internal uint Id { get; }
internal PartyFinderPayload(uint id)
{
Id = id;
}
protected override byte[] EncodeImpl() => throw new NotImplementedException();
protected override void DecodeImpl(BinaryReader reader, long endOfStream) =>
throw new NotImplementedException();
}
internal class AchievementPayload : Payload
{
public override PayloadType Type => (PayloadType)0x51;
internal uint Id { get; }
internal AchievementPayload(uint id)
{
Id = id;
}
protected override byte[] EncodeImpl() => throw new NotImplementedException();
protected override void DecodeImpl(BinaryReader reader, long endOfStream) =>
throw new NotImplementedException();
}
internal class UriPayload(Uri uri) : Payload
{
public override PayloadType Type => (PayloadType)0x52;
public Uri Uri { get; } = uri;
private const string DefaultScheme = "https";
private static readonly string[] ExpectedSchemes = ["http", "https"];
// Parses a raw URI string. Defaults to https:// if no scheme is present.
// Throws UriFormatException for empty input or unsupported schemes.
public static UriPayload ResolveUri(string rawUri)
{
ArgumentNullException.ThrowIfNull(rawUri);
if (string.IsNullOrWhiteSpace(rawUri))
throw new UriFormatException("URI cannot be empty or whitespace.");
if (ExpectedSchemes.Any(scheme => rawUri.StartsWith($"{scheme}://")))
return new UriPayload(new Uri(rawUri));
if (rawUri.Contains("://"))
throw new UriFormatException($"Unsupported scheme in URL: {rawUri}");
return new UriPayload(new Uri($"{DefaultScheme}://{rawUri}"));
}
protected override void DecodeImpl(BinaryReader reader, long endOfStream) =>
throw new NotImplementedException();
protected override byte[] EncodeImpl() => throw new NotImplementedException();
}
internal class EmotePayload : Payload
{
public override PayloadType Type => (PayloadType)0x53;
public string Code = string.Empty;
public static EmotePayload ResolveEmote(string code) => new EmotePayload { Code = code };
protected override void DecodeImpl(BinaryReader reader, long endOfStream) =>
throw new NotImplementedException();
protected override byte[] EncodeImpl() => throw new NotImplementedException();
}