sharp-chat/SharpChat/ChatPacketHandlerContext.cs

28 lines
848 B
C#
Raw Normal View History

2023-02-16 21:16:06 +00:00
using System;
namespace SharpChat {
public class ChatPacketHandlerContext {
public string Text { get; }
public ChatContext Chat { get; }
public ChatUserSession Session { get; }
public ChatPacketHandlerContext(
string text,
ChatContext chat,
ChatUserSession session
) {
Text = text ?? throw new ArgumentNullException(nameof(text));
Chat = chat ?? throw new ArgumentNullException(nameof(chat));
Session = session ?? throw new ArgumentNullException(nameof(session));
}
public bool CheckPacketId(string packetId) {
return Text == packetId || Text.StartsWith(packetId + '\t');
}
public string[] SplitText(int expect) {
return Text.Split('\t', expect + 1);
}
}
}