2023-02-16 21:16:06 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace SharpChat {
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public class PacketHandlerContext {
|
2023-02-16 21:16:06 +00:00
|
|
|
|
public string Text { get; }
|
|
|
|
|
public ChatContext Chat { get; }
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public ConnectionInfo Connection { get; }
|
2023-02-16 21:16:06 +00:00
|
|
|
|
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public PacketHandlerContext(
|
2023-02-16 21:16:06 +00:00
|
|
|
|
string text,
|
|
|
|
|
ChatContext chat,
|
2024-05-19 02:17:51 +00:00
|
|
|
|
ConnectionInfo connection
|
2023-02-16 21:16:06 +00:00
|
|
|
|
) {
|
2024-05-19 01:53:14 +00:00
|
|
|
|
Text = text;
|
|
|
|
|
Chat = chat;
|
|
|
|
|
Connection = 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|