sharp-chat/SharpChat.SockChat/PacketsC2S/C2SPacketHandlerContext.cs

21 lines
689 B
C#

namespace SharpChat.SockChat.PacketsC2S {
public class C2SPacketHandlerContext {
public string Text { get; }
public SockChatContext Chat { get; }
public SockChatConnectionInfo Connection { get; }
public C2SPacketHandlerContext(string text, SockChatContext chat, SockChatConnectionInfo 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);
}
}
}