org.rabbitcontrol.rcp.transport.netty.RCPServerDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rcp Show documentation
Show all versions of rcp Show documentation
RabbitControl is a binary data-format definition to describe data values and ui-elements.
The newest version!
package org.rabbitcontrol.rcp.transport.netty;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import org.rabbitcontrol.rcp.RCP;
import org.rabbitcontrol.rcp.transport.ServerTransporter;
import org.rabbitcontrol.rcp.transport.ServerTransporterListener;
import java.util.List;
import static org.rabbitcontrol.rcp.RCP.bytesToHex;
public class RCPServerDecoder extends MessageToMessageDecoder {
private final ServerTransporter transporter;
private final ServerTransporterListener listener;
private final ChannelManager channelManager;
public RCPServerDecoder(final ServerTransporter _transporter,
final ServerTransporterListener _listener,
final ChannelManager _channelManager) {
transporter = _transporter;
listener = _listener;
channelManager = _channelManager;
}
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
if (channelManager != null) {
channelManager.addChannel(ctx.channel());
}
super.channelActive(ctx);
}
@Override
public void channelInactive(final ChannelHandlerContext ctx) throws Exception {
if (channelManager != null) {
channelManager.removeChannel(ctx.channel());
}
super.channelInactive(ctx);
}
@Override
protected void decode(
final ChannelHandlerContext ctx, final ByteBuf msg, final List