System.out.println("[Server]:" + msg);
}
public static void bootServer() {
// More terse code to setup the server
ServerBootstrap bootstrap = new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
// Set up the pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(
new ObjectDecoder(ClassResolvers.cacheDisabled(getClass().getClassLoader())),
new SimpleChannelHandler() {
public void messageReceived(ChannelHandlerContext ctx,MessageEvent e) throws Exception {
Date date = (Date)e.getMessage();
slog("Hey Guys ! I got a date ! [" + date + "]");
super.messageReceived(ctx, e);
}
}
);
};
});
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress("0.0.0.0", 8080));
slog("Listening on 8080");
}