Commit 00ad4d86 authored by 赵啸非's avatar 赵啸非

修改消息组件

parent da54c2c1
...@@ -29,7 +29,7 @@ public class NettyStartedService implements IApplicationStartedService { ...@@ -29,7 +29,7 @@ public class NettyStartedService implements IApplicationStartedService {
public void start() { public void start() {
logger.info("开始netty服务...."); logger.info("开始netty服务....");
thread = new Thread(() -> { thread = new Thread(() -> {
controlServer.run(7788); controlServer.run(61112);
}); });
thread.setDaemon(true); thread.setDaemon(true);
thread.start(); thread.start();
......
...@@ -28,12 +28,11 @@ public class UDPClientHandler extends SimpleChannelInboundHandler<DatagramPacket ...@@ -28,12 +28,11 @@ public class UDPClientHandler extends SimpleChannelInboundHandler<DatagramPacket
@Override @Override
public void channelActive(ChannelHandlerContext ctx) throws Exception { public void channelActive(ChannelHandlerContext ctx) throws Exception {
log.info("remoteAddress:{}", ctx.channel().remoteAddress()); log.info("remoteAddress:{}", ctx.channel().remoteAddress());
ctx.executor().parent().execute(new Runnable() { ctx.executor().parent().execute(new Runnable() {
@Override @Override
public void run() { public void run() {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
log.info("send msg:{}",i);
ctx.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer("我在广播" + i, Charset.forName("utf-8")), ctx.writeAndFlush(new DatagramPacket(Unpooled.copiedBuffer("我在广播" + i, Charset.forName("utf-8")),
new InetSocketAddress("255.255.255.255", 7788))); new InetSocketAddress("255.255.255.255", 7788)));
try { try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment