package Netty; import java.util.Vector; import java.util.concurrent.TimeUnit; import PbuliClass.Systems; import home.Open_soft_dialog; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.*; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.codec.string.StringEncoder; import io.netty.handler.timeout.IdleStateHandler; import rtkanchor.Dell_jizhan; import rtkanchor.Jizhan; public class NettyServer { static Vector chnvec=new Vector(); //¼àÌý¶Ë¿ÚµÄ¼¯ºÏ static Vector portvec=new Vector(); static { String port12=Systems.getTcpreceiveport(); portvec.add(port12); if(Systems.isBiandianzhan()) { Vector jizhan_vector=Dell_jizhan.getJizhan_vector(); int size=jizhan_vector.size(); for(int i=0;i() {// ×îºó°ó¶¨I/OʼþµÄ´¦ÀíÀà public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline=ch.pipeline(); /** * readerIdleTime ¶à³¤Ê±¼äûÓжÁ£¬¾Í»á·¢ËÍÒ»¸öÐÄÌø¼ì²â°ü¼ì²âÊÇ·ñÁ¬½Ó * writerIdleTime ¶à³¤Ê±¼äûÓÐд£¬¾Í»á·¢ËÍÒ»¸öÐÄÌø¼ì²â°ü¼ì²âÊÇ·ñÁ¬½Ó * allIdleTime ¶à³¤Ê±¼äûÓжÁ/д£¬¾Í»á·¢ËÍÒ»¸öÐÄÌø¼ì²â°ü¼ì²âÊÇ·ñÁ¬½Ó * */ pipeline.addLast("decoder", new StringEncoder()); //Ïòpipeline¼ÓÈë±àÂëÆ÷ pipeline.addLast("encoder", new StringEncoder()); //Ïòpipeline¼ÓÈë½âÂëÆ÷ pipeline.addLast(new IdleStateHandler(120,120,120,TimeUnit.SECONDS)); pipeline.addLast(new NettyServerHandler());// pipeline.addLast(new GroupChatServerHandler()); } }); //°ó¶¨Ò»¸ö¶Ë¿Ú²¢ÇÒͬ²½, Éú³ÉÁËÒ»¸ö ChannelFuture ¶ÔÏó //Æô¶¯·þÎñÆ÷(²¢°ó¶¨¶Ë¿Ú) for(int i=0;i