// create new session
Session session = new PipeSession();
// set packet encoder and decoder
session.setPacketEncoder(new SerialEncoder());
session.setPacketDecoder(new SerialDecoder());
// set session handler
session.setSessionHandler(new SessionHandlerAdapter() {
public void sessionStarted(Session session) throws Exception {