27 lines
861 B
C#
27 lines
861 B
C#
using System;
|
|
|
|
namespace SharpChat {
|
|
public class ChatPacketHandlerContext {
|
|
public string Text { get; }
|
|
public ChatContext Chat { get; }
|
|
public ChatConnection Connection { get; }
|
|
|
|
public ChatPacketHandlerContext(
|
|
string text,
|
|
ChatContext chat,
|
|
ChatConnection connection
|
|
) {
|
|
Text = text ?? throw new ArgumentNullException(nameof(text));
|
|
Chat = chat ?? throw new ArgumentNullException(nameof(chat));
|
|
Connection = connection ?? throw new ArgumentNullException(nameof(connection));
|
|
}
|
|
|
|
public bool CheckPacketId(string packetId) {
|
|
return Text == packetId || Text.StartsWith(packetId + '\t');
|
|
}
|
|
|
|
public string[] SplitText(int expect) {
|
|
return Text.Split('\t', expect + 1);
|
|
}
|
|
}
|
|
}
|