use of de.datasecs.hydra.shared.protocol.packets.serialization.PacketDecoder in project Hydra by DataSecs.
the class HydraChannelInitializer method initChannel.
@Override
protected void initChannel(SocketChannel channel) {
ChannelPipeline pipeline = channel.pipeline();
// In
pipeline.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4));
pipeline.addLast(new PacketDecoder(protocol));
// Out
pipeline.addLast(new LengthFieldPrepender(4));
pipeline.addLast(new PacketEncoder(protocol));
HydraSession session = new HydraSession(channel, protocol);
pipeline.addLast(session);
// Add sessions to protocol, to keep track of them
if (isServer) {
protocol.addSession(session);
} else {
protocol.setClientSession(session);
}
// Inform SessionListener about new session
protocol.callSessionListener(true, session);
}
use of de.datasecs.hydra.shared.protocol.packets.serialization.PacketDecoder in project Hydra by DataSecs.
the class HydraChannelInitializer method initChannel.
@Override
protected void initChannel(C channel) {
ChannelPipeline pipeline = channel.pipeline();
// In
pipeline.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4));
pipeline.addLast(new PacketDecoder(protocol));
// Out
pipeline.addLast(new LengthFieldPrepender(4));
pipeline.addLast(new PacketEncoder(protocol));
/*
if (!useUDP) {
TCPHydraSession session = new TCPHydraSession(channel, protocol);
pipeline.addLast(session);
} else {
UDPHydraSession session = new UDPHydraSession(channel, protocol);
pipeline.addLast(session);
}
*/
HydraSession session = new HydraSession(channel, protocol);
pipeline.addLast(session);
// Add sessions to protocol, to keep track of them
if (isServer) {
protocol.addSession(session);
} else {
protocol.setClientSession(session);
}
if (!useUDP) {
if (protocol.getSessionListener() != null) {
// Inform SessionListener about new session
protocol.callSessionListener(true, session);
} else if (protocol.getSessionConsumer() != null) {
// Inform SessionConsumer about new session
protocol.callSessionConsumer(true, session);
}
}
}
Aggregations