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; }
|
2023-02-16 21:25:41 +00:00
|
|
|
|
public ChatConnection Connection { get; private set; }
|
2023-02-08 23:53:42 +00:00
|
|
|
|
public int MaxMessageLength { get; private set; }
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
2023-02-08 23:53:42 +00:00
|
|
|
|
public AuthSuccessPacket(
|
|
|
|
|
ChatUser user,
|
|
|
|
|
ChatChannel channel,
|
2023-02-16 21:25:41 +00:00
|
|
|
|
ChatConnection connection,
|
2023-02-08 23:53:42 +00:00
|
|
|
|
int maxMsgLength
|
|
|
|
|
) {
|
2022-08-30 15:00:58 +00:00
|
|
|
|
User = user ?? throw new ArgumentNullException(nameof(user));
|
|
|
|
|
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
|
2023-02-16 21:25:41 +00:00
|
|
|
|
Connection = connection ?? throw new ArgumentNullException(nameof(connection));
|
2023-02-08 23:53:42 +00:00
|
|
|
|
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');
|
2023-02-08 23:53:42 +00:00
|
|
|
|
sb.Append(MaxMessageLength);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
|
|
|
|
return new[] { sb.ToString() };
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|