pl.grzeslowski.jsupla.protocol.api.decoders.sc.SuplaEventDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protocol Show documentation
Show all versions of protocol Show documentation
Uploads all artifacts belonging to configuration ':protocol:archives'
The newest version!
package pl.grzeslowski.jsupla.protocol.api.decoders.sc;
import lombok.val;
import pl.grzeslowski.jsupla.protocol.api.decoders.PrimitiveDecoder;
import pl.grzeslowski.jsupla.protocol.api.structs.sc.SuplaEvent;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;
@javax.annotation.Generated(value="Struct original name: TSC_SuplaEvent", date = "2024-09-06T08:44:37.722Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class SuplaEventDecoder implements pl.grzeslowski.jsupla.protocol.api.decoders.sc.ServerClientDecoder {
public static final SuplaEventDecoder INSTANCE = new SuplaEventDecoder();
@Override
public SuplaEvent decode(byte[] bytes, int offset) {
val event = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
offset += INT_SIZE;
val channelId = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
offset += INT_SIZE;
val durationMS = PrimitiveDecoder.INSTANCE.parseUnsignedInt(bytes, offset);
offset += INT_SIZE;
val senderId = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
offset += INT_SIZE;
val senderNameSize = PrimitiveDecoder.INSTANCE.parseUnsignedInt(bytes, offset);
offset += INT_SIZE;
val senderName = PrimitiveDecoder.INSTANCE.copyOfRangeByte(bytes, offset, offset + (int) senderNameSize);
offset += senderNameSize * BYTE_SIZE;
return new SuplaEvent(event, channelId, durationMS, senderId, senderNameSize, senderName);
}
}