sharp-chat/SharpChat/PacketHandlerContext.cs

25 lines
685 B
C#

namespace SharpChat {
public class PacketHandlerContext {
public string Text { get; }
public ChatContext Chat { get; }
public ConnectionInfo Connection { get; }
public PacketHandlerContext(
string text,
ChatContext chat,
ConnectionInfo connection
) {
Text = text;
Chat = chat;
Connection = connection;
}
public bool CheckPacketId(string packetId) {
return Text == packetId || Text.StartsWith(packetId + '\t');
}
public string[] SplitText(int expect) {
return Text.Split('\t', expect + 1);
}
}
}