sharp-chat/SharpChat/Packet/ContextUsersPacket.cs
flashwave e17aed7c25
Switched to Index brand random Snowflakes instead of SharpIds.
If you were still handling message ids as integers in an environment that can't handle signed 64-bit integers you're going to be having a fun time after this update!
2025-04-25 20:05:57 +00:00

26 lines
795 B
C#

using System.Text;
namespace SharpChat.Packet {
public class ContextUsersPacket(IEnumerable<ChatUser> users) : IServerPacket {
public IEnumerable<ChatUser> Users { get; private set; } = users?.Where(u => u != null) ?? throw new ArgumentNullException(nameof(users));
public IEnumerable<string> Pack() {
StringBuilder sb = new();
sb.Append('7');
sb.Append('\t');
sb.Append('0');
sb.Append('\t');
sb.Append(Users.Count());
foreach(ChatUser user in Users) {
sb.Append('\t');
sb.Append(user.Pack());
sb.Append('\t');
sb.Append('1'); // visibility flag
}
yield return sb.ToString();
}
}
}