All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.grzeslowski.jsupla.protocol.api.decoders.cs.PnClientTokenDecoder Maven / Gradle / Ivy

The newest version!
package pl.grzeslowski.jsupla.protocol.api.decoders.cs;

import lombok.val;
import pl.grzeslowski.jsupla.protocol.api.decoders.PrimitiveDecoder;
import pl.grzeslowski.jsupla.protocol.api.structs.cs.PnClientToken;
import static pl.grzeslowski.jsupla.protocol.api.JavaConsts.*;
import static pl.grzeslowski.jsupla.protocol.api.consts.ProtoConsts.*;

@javax.annotation.Generated(value="Struct original name: TCS_PnClientToken", date = "2024-09-06T08:44:37.648Z[Etc/UTC]")
@lombok.NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
public class PnClientTokenDecoder implements pl.grzeslowski.jsupla.protocol.api.decoders.cs.ClientServerDecoder {
	public static final PnClientTokenDecoder INSTANCE = new PnClientTokenDecoder();

    @Override
	public PnClientToken decode(byte[] bytes, int offset) {
		val developmentEnv = PrimitiveDecoder.INSTANCE.parseUnsignedByte(bytes, offset);
		offset += BYTE_SIZE;

		val platform = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
		offset += INT_SIZE;

		val appId = PrimitiveDecoder.INSTANCE.parseInt(bytes, offset);
		offset += INT_SIZE;

		val profileName = PrimitiveDecoder.INSTANCE.copyOfRangeByte(bytes, offset, offset + (int) SUPLA_PN_PROFILE_NAME_MAXSIZE);
		offset += SUPLA_PN_PROFILE_NAME_MAXSIZE * BYTE_SIZE;

		val realTokenSize = PrimitiveDecoder.INSTANCE.parseUnsignedShort(bytes, offset);
		offset += SHORT_SIZE;

		val tokenSize = PrimitiveDecoder.INSTANCE.parseUnsignedShort(bytes, offset);
		offset += SHORT_SIZE;

		val token = PrimitiveDecoder.INSTANCE.copyOfRangeByte(bytes, offset, offset + (int) tokenSize);
		offset += tokenSize * BYTE_SIZE;
		
	    return new PnClientToken(developmentEnv, platform, appId, profileName, realTokenSize, tokenSize, token);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy