Skip to content

Instantly share code, notes, and snippets.

@GauravBhardwaj
Created April 20, 2014 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GauravBhardwaj/11107910 to your computer and use it in GitHub Desktop.
Save GauravBhardwaj/11107910 to your computer and use it in GitHub Desktop.
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.group.ChannelGroup;
import io.netty.channel.group.DefaultChannelGroup;
import io.netty.handler.ssl.SslHandler;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.concurrent.GlobalEventExecutor;
import java.net.InetAddress;
/**
* Handles a server-side channel.
*/
public class ChatServerHandler extends SimpleChannelInboundHandler<String> {
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception{
//invoked as many times as your client connects
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
ctx.close();
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg)
throws Exception {
System.out.println("message recieved is: "+msg.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment