sharp-chat/SharpChat/Packet/TypingPacket.cs

30 lines
939 B
C#
Raw Permalink Normal View History

2022-08-30 15:00:58 +00:00
using System;
using System.Collections.Generic;
using System.Text;
namespace SharpChat.Packet {
public class TypingPacket : ServerPacket {
public ChatChannel Channel { get; }
public ChatChannelTyping TypingInfo { get; }
public TypingPacket(ChatChannel channel, ChatChannelTyping typingInfo) {
Channel = channel;
TypingInfo = typingInfo ?? throw new ArgumentNullException(nameof(typingInfo));
}
public override IEnumerable<string> Pack() {
StringBuilder sb = new StringBuilder();
sb.Append((int)SockChatServerPacket.Typing);
sb.Append('\t');
sb.Append(Channel?.TargetName ?? string.Empty);
sb.Append('\t');
sb.Append(TypingInfo.User.UserId);
sb.Append('\t');
sb.Append(TypingInfo.Started.ToUnixTimeSeconds());
yield return sb.ToString();
}
}
}