sharp-chat/SharpChat/C2SPacketHandlerContext.cs

20 lines
641 B
C#
Raw Normal View History

namespace SharpChat;
2023-02-16 22:16:06 +01:00
public class C2SPacketHandlerContext(
string text,
Context chat,
Connection connection
) {
public string Text { get; } = text ?? throw new ArgumentNullException(nameof(text));
public Context Chat { get; } = chat ?? throw new ArgumentNullException(nameof(chat));
public Connection Connection { get; } = connection ?? throw new ArgumentNullException(nameof(connection));
2023-02-16 22:16:06 +01:00
public bool CheckPacketId(string packetId) {
return Text == packetId || Text.StartsWith(packetId + '\t');
}
public string[] SplitText(int expect) {
return Text.Split('\t', expect + 1);
2023-02-16 22:16:06 +01:00
}
}