首页>代码>基于netty开发的在线聊天程序netty-chat>/netty-demo-m/src/main/java/com/example/netty/config/RegisterConfig.java
package com.example.netty.config; import com.example.netty.handlercfg.NettyChildChannelHandler; import com.example.netty.udpserver.UdpNettyServer; import com.example.netty.websocketserver.WebSocketNettyServer; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.ChannelHandler; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import javax.annotation.Resource; @Configuration public class RegisterConfig{ @Resource(name = "nettyChildChannelHandler") private NettyChildChannelHandler nettyChildChannelHandler; @Resource(name = "udpNettyServerHandler") private ChannelHandler udpNettyServerHandler; @Value("${netty.websocket.port}") private int webSocketPort; @Value("${netty.udp.port}") private int updPort; @Value("${netty.udp.host}") private String udpHost; @Bean public WebSocketNettyServer getWebSocketServer() { WebSocketNettyServer webSocketServer = new WebSocketNettyServer(); webSocketServer.setPort(webSocketPort); webSocketServer.setChildChannelHandler(nettyChildChannelHandler); return webSocketServer; } @Bean public UdpNettyServer getUdpSocketServer() { UdpNettyServer udpNettyServer = new UdpNettyServer(); udpNettyServer.setPort(updPort); udpNettyServer.setHost(udpHost); udpNettyServer.setChildChannelHandler(udpNettyServerHandler); return udpNettyServer; } @Bean("bossGroup") public EventLoopGroup getBossGroup() { return new NioEventLoopGroup(); } @Bean("workerGroup") public EventLoopGroup getWorkerGroup() { return new NioEventLoopGroup(); } @Bean public ServerBootstrap getServerBootstrap(){ return new ServerBootstrap(); } }
最近下载更多
wanglinddad LV54
4月12日
shuangfu LV24
2023年10月19日
qq1061521319 LV4
2023年9月1日
cto1206 LV3
2023年8月29日
youzitao LV11
2023年4月17日
荣》Cowboy LV12
2023年4月12日
dixiu000 LV4
2023年2月28日
Uting LV3
2023年2月21日
675104182 LV14
2023年1月31日
wayshort LV2
2022年10月29日
最近浏览更多
wanglinddad LV54
4月12日
微信网友_6444139264921600 LV6
4月10日
silences_ftjh LV10
3月22日
微信网友_6902352269217792 LV3
3月12日
Xiaobaiya11 LV2
3月4日
3334004690 LV3
2月20日
打烊1234 LV2
1月30日
axdfer
1月2日
暂无贡献等级
ddy-ddy LV4
2023年12月27日
erqiu2013 LV18
2023年12月27日