34 lines
1.1 KiB
C#
34 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace SharpChat.Packet {
|
|
public class UserUpdateNotificationPacket : ServerPacket {
|
|
public string PreviousName { get; private set; }
|
|
public string NewName { get; private set; }
|
|
public DateTimeOffset Timestamp { get; }
|
|
|
|
public UserUpdateNotificationPacket(string previousName, string newName) {
|
|
PreviousName = previousName ?? throw new ArgumentNullException(nameof(previousName));
|
|
NewName = newName ?? throw new ArgumentNullException(nameof(newName));
|
|
Timestamp = DateTimeOffset.Now;
|
|
}
|
|
|
|
public override IEnumerable<string> Pack() {
|
|
StringBuilder sb = new();
|
|
|
|
sb.Append('2');
|
|
sb.Append('\t');
|
|
sb.Append(Timestamp.ToUnixTimeSeconds());
|
|
sb.Append("\t-1\t0\fnick\f");
|
|
sb.Append(PreviousName);
|
|
sb.Append('\f');
|
|
sb.Append(NewName);
|
|
sb.Append('\t');
|
|
sb.Append(SequenceId);
|
|
sb.Append("\t10010");
|
|
|
|
yield return sb.ToString();
|
|
}
|
|
}
|
|
}
|