sharp-chat/SharpChat.Protocol.SockChat/Packets/ContextClearPacket.cs

39 lines
1 KiB
C#
Raw Permalink Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Channels;
using System.Text;
namespace SharpChat.Protocol.SockChat.Packets {
public enum ContextClearMode {
Messages = 0,
Users = 1,
Channels = 2,
MessagesUsers = 3,
MessagesUsersChannels = 4,
}
public class ContextClearPacket : ServerPacket {
public IChannel Channel { get; private set; }
public ContextClearMode Mode { get; private set; }
public bool IsGlobal
=> Channel == null;
public ContextClearPacket(IChannel channel, ContextClearMode mode) {
Channel = channel;
Mode = mode;
}
protected override string DoPack() {
StringBuilder sb = new();
sb.Append((int)ServerPacketId.ContextClear);
sb.Append(IServerPacket.SEPARATOR);
sb.Append((int)Mode);
sb.Append(IServerPacket.SEPARATOR);
if(!IsGlobal)
sb.Append(Channel.Name);
return sb.ToString();
}
}
}