29 lines
834 B
C#
29 lines
834 B
C#
using System.Text;
|
|
|
|
namespace SharpChat.Packet {
|
|
public class ChannelsPopulatePacket : ServerPacket {
|
|
public record ListEntry(string Name, bool HasPassword, bool IsTemporary);
|
|
|
|
private readonly ListEntry[] Entries;
|
|
|
|
public ChannelsPopulatePacket(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();
|
|
}
|
|
}
|
|
}
|