sharp-chat/SharpChat/PacketsS2C/ChannelsPopulateS2CPacket.cs

29 lines
849 B
C#

using System.Text;
namespace SharpChat.PacketsS2C {
public class ChannelsPopulateS2CPacket : SockChatS2CPacket {
public record ListEntry(string Name, bool HasPassword, bool IsTemporary);
private readonly ListEntry[] Entries;
public ChannelsPopulateS2CPacket(ListEntry[] entries) {
Entries = entries;
}
public override string Pack() {
StringBuilder sb = new();
sb.AppendFormat("7\t2\t{0}", Entries.Length);
foreach(ListEntry entry in Entries)
sb.AppendFormat(
"\t{0}\t{1}\t{2}",
SockChatUtility.SanitiseChannelName(entry.Name),
entry.HasPassword ? 1 : 0,
entry.IsTemporary ? 1 : 0
);
return sb.ToString();
}
}
}