sharp-chat/SharpChat.Protocol.SockChat/Channels/IChannelExtensions.cs

22 lines
696 B
C#
Raw Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Channels;
using SharpChat.Protocol.SockChat.Packets;
using System.Text;
namespace SharpChat.Protocol.SockChat.Channels {
public static class IChannelExtensions {
public static string Pack(this IChannel channel) {
StringBuilder sb = new();
channel.Pack(sb);
return sb.ToString();
}
public static void Pack(this IChannel channel, StringBuilder sb) {
sb.Append(channel.Name);
sb.Append(IServerPacket.SEPARATOR);
sb.Append(channel.HasPassword ? '1' : '0');
sb.Append(IServerPacket.SEPARATOR);
sb.Append(channel.IsTemporary ? '1' : '0');
}
}
}