| | |
| | | package com.xcong.excoin.netty.initalizer; |
| | | |
| | | import com.xcong.excoin.netty.handler.WebSocketServerHandler; |
| | | import com.xcong.excoin.utils.SpringContextHolder; |
| | | import io.netty.channel.ChannelInitializer; |
| | | import io.netty.channel.ChannelPipeline; |
| | | import io.netty.channel.socket.nio.NioSocketChannel; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @email wangdoubleone@gmail.com |
| | |
| | | @Component |
| | | public class WebSocketServerInitializer extends ChannelInitializer<NioSocketChannel> { |
| | | |
| | | @Autowired |
| | | private WebSocketServerHandler webSocketServerHandler; |
| | | // @Autowired |
| | | // private WebSocketServerHandler webSocketServerHandler; |
| | | |
| | | @Override |
| | | protected void initChannel(NioSocketChannel ch) throws Exception { |
| | |
| | | cp.addLast(new HttpObjectAggregator(65536)); |
| | | cp.addLast(new ChunkedWriteHandler()); |
| | | // 心跳 |
| | | ch.pipeline().addLast(new IdleStateHandler(0, 10, 0)); |
| | | // ch.pipeline().addLast(new IdleStateHandler(0, 10, 0)); |
| | | // 自定义业务handler |
| | | cp.addLast(webSocketServerHandler); |
| | | cp.addLast(new WebSocketServerHandler()); |
| | | } |
| | | } |