38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System;
|
|
using System.Text;
|
|
|
|
namespace SharpChat.Packet {
|
|
public class WhoServerResponsePacket : ServerPacket {
|
|
private readonly long Timestamp;
|
|
private readonly string[] Users;
|
|
private readonly string SelfName;
|
|
|
|
public WhoServerResponsePacket(string[] users, string selfName) {
|
|
Timestamp = DateTimeOffset.Now.ToUnixTimeSeconds();
|
|
Users = users;
|
|
SelfName = selfName;
|
|
}
|
|
|
|
public override string Pack() {
|
|
StringBuilder sb = new();
|
|
|
|
sb.AppendFormat("2\t{0}\t-1\t0\fwho\f", Timestamp);
|
|
|
|
foreach(string userName in Users) {
|
|
sb.Append(@"<a href=""javascript:void(0);"" onclick=""UI.InsertChatText(this.innerHTML);""");
|
|
|
|
if(userName.Equals(SelfName, StringComparison.InvariantCultureIgnoreCase))
|
|
sb.Append(@" style=""font-weight: bold;""");
|
|
|
|
sb.AppendFormat(@">{0}</a>, ", userName);
|
|
}
|
|
|
|
if(Users.Length > 0)
|
|
sb.Length -= 2;
|
|
|
|
sb.AppendFormat("\t{0}\t10010", SequenceId);
|
|
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|