sharp-chat/SharpChat/Packet/AuthSuccessPacket.cs

39 lines
1.2 KiB
C#
Raw 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 AuthSuccessPacket : ServerPacket {
public ChatUser User { get; private set; }
public ChatChannel Channel { get; private set; }
public ChatUserSession Session { get; private set; }
public int MaxMessageLength { get; private set; }
2022-08-30 15:00:58 +00:00
public AuthSuccessPacket(
ChatUser user,
ChatChannel channel,
ChatUserSession sess,
int maxMsgLength
) {
2022-08-30 15:00:58 +00:00
User = user ?? throw new ArgumentNullException(nameof(user));
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
Session = sess ?? throw new ArgumentNullException(nameof(channel));
MaxMessageLength = maxMsgLength;
2022-08-30 15:00:58 +00:00
}
public override IEnumerable<string> Pack() {
2023-02-07 15:01:56 +00:00
StringBuilder sb = new();
2022-08-30 15:00:58 +00:00
2023-02-07 14:34:31 +00:00
sb.Append('1');
2022-08-30 15:00:58 +00:00
sb.Append("\ty\t");
sb.Append(User.Pack());
sb.Append('\t');
sb.Append(Channel.Name);
sb.Append('\t');
sb.Append(MaxMessageLength);
2022-08-30 15:00:58 +00:00
return new[] { sb.ToString() };
}
}
}