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

com.iteaj.iot.client.codec.ByteToMessageDecoderClient Maven / Gradle / Ivy

package com.iteaj.iot.client.codec;

import com.iteaj.iot.SocketMessage;
import com.iteaj.iot.client.ClientConnectProperties;
import com.iteaj.iot.client.TcpSocketClient;
import com.iteaj.iot.client.ClientComponent;
import com.iteaj.iot.codec.adapter.ByteToMessageDecoderAdapter;
import com.iteaj.iot.config.ConnectProperties;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

public class ByteToMessageDecoderClient extends TcpSocketClient {

    public ByteToMessageDecoderClient(ClientComponent clientComponent, ClientConnectProperties config) {
        super(clientComponent, config);
    }

    @Override
    protected ByteToMessageDecoderAdapter createProtocolDecoder() {
        return new ByteToMessageDecoderAdapter() {

            @Override
            public SocketMessage proxy(ChannelHandlerContext ctx, ByteBuf decode) throws Exception {
                return ByteToMessageDecoderClient.this.getClientComponent().proxy(ctx, decode);
            }

            @Override
            public SocketMessage createMessage(byte[] message) {
                return ByteToMessageDecoderClient.this.getClientComponent().createMessage(message);
            }

            @Override
            public SocketMessage doDecode(ChannelHandlerContext ctx, ByteBuf in) {
                return ByteToMessageDecoderClient.this.getClientComponent().doDecode(ctx, in);
            }

            @Override
            public Class getMessageClass() {
                return ByteToMessageDecoderClient.this.getClientComponent().getMessageClass();
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy