2024-05-10 15:24:43 +00:00
|
|
|
|
namespace SharpChat {
|
2022-08-30 15:00:58 +00:00
|
|
|
|
public interface IServerPacket {
|
|
|
|
|
long SequenceId { get; }
|
2024-05-10 15:24:43 +00:00
|
|
|
|
string Pack();
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class ServerPacket : IServerPacket {
|
|
|
|
|
public long SequenceId { get; }
|
|
|
|
|
|
|
|
|
|
public ServerPacket(long sequenceId = 0) {
|
|
|
|
|
// Allow sequence id to be manually set for potential message repeats
|
2023-02-16 22:56:50 +00:00
|
|
|
|
SequenceId = sequenceId > 0 ? sequenceId : SharpId.Next();
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-05-10 15:24:43 +00:00
|
|
|
|
public abstract string Pack();
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|