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