sharp-chat/SharpChat/PacketHandlerContext.cs

27 lines
700 B
C#

using System;
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);
}
}
}