Начало трансляции сервероного кода к новому протоколу

This commit is contained in:
RoyceDa
2026-04-18 17:50:23 +02:00
parent 068492b56d
commit 33582e2730
123 changed files with 3380 additions and 2745 deletions

View File

@@ -0,0 +1,40 @@
package im.rosetta.network.codec;
import io.orprotocol.ProtocolException;
import io.orprotocol.buffer.Buffer;
import io.orprotocol.codec.Codec;
import io.orprotocol.tlv.read.TlvReader;
import io.orprotocol.tlv.write.TlvWriter;
import im.rosetta.network.packet.PacketDelivery;
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
public class PacketDeliveryCodec implements Codec<PacketDelivery> {
private static final int F_MESSAGE_ID = 1;
private static final int F_TO_PUBLIC_KEY = 2;
@Override
public PacketDelivery decode(Buffer data, int version) throws ProtocolException {
byte[] payload = data.readBytes(data.remaining());
TlvReader reader = new TlvReader(payload);
PacketDelivery packet = new PacketDelivery();
if (version >= 1) {
packet.messageId = reader.getString(F_MESSAGE_ID);
}
if (version >= 1) {
packet.toPublicKey = reader.getString(F_TO_PUBLIC_KEY);
}
return packet;
}
@Override
public byte[] encode(PacketDelivery packet, int version) throws ProtocolException {
TlvWriter writer = new TlvWriter();
if (version >= 1) {
if (packet.messageId != null) writer.writeString(F_MESSAGE_ID, packet.messageId);
}
if (version >= 1) {
if (packet.toPublicKey != null) writer.writeString(F_TO_PUBLIC_KEY, packet.toPublicKey);
}
return writer.toByteArray();
}
}