38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
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 ChatConnection Connection { get; private set; }
|
|
public int MaxMessageLength { get; private set; }
|
|
|
|
public AuthSuccessPacket(
|
|
ChatUser user,
|
|
ChatChannel channel,
|
|
ChatConnection connection,
|
|
int maxMsgLength
|
|
) {
|
|
User = user ?? throw new ArgumentNullException(nameof(user));
|
|
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
|
|
Connection = connection ?? throw new ArgumentNullException(nameof(connection));
|
|
MaxMessageLength = maxMsgLength;
|
|
}
|
|
|
|
public override IEnumerable<string> Pack() {
|
|
StringBuilder sb = new();
|
|
|
|
sb.Append('1');
|
|
sb.Append("\ty\t");
|
|
sb.Append(User.Pack());
|
|
sb.Append('\t');
|
|
sb.Append(Channel.Name);
|
|
sb.Append('\t');
|
|
sb.Append(MaxMessageLength);
|
|
|
|
return new[] { sb.ToString() };
|
|
}
|
|
}
|
|
}
|