提交 a26866f2 编写于 作者: 武汉红喜's avatar 武汉红喜

rename Class

上级 e23c24e3
......@@ -12,7 +12,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
/**
* Created by shenhongxi on 2018/10/5.
*/
public class TimeClient {
public class HelloClient {
public void connect(int port, String host) throws Exception {
// 配置客户端NIO线程组
......@@ -24,7 +24,7 @@ public class TimeClient {
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
socketChannel.pipeline().addLast(new TimeClientHandler());
socketChannel.pipeline().addLast(new HelloClientHandler());
}
});
......@@ -40,6 +40,6 @@ public class TimeClient {
}
public static void main(String[] args) throws Exception {
new TimeClient().connect(8080, "127.0.0.1");
new HelloClient().connect(8080, "127.0.0.1");
}
}
......@@ -8,11 +8,11 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
/**
* Created by shenhongxi on 2018/10/5.
*/
public class TimeClientHandler extends ChannelInboundHandlerAdapter {
public class HelloClientHandler extends ChannelInboundHandlerAdapter {
private final ByteBuf firstMessage;
public TimeClientHandler() {
public HelloClientHandler() {
byte[] req = "QUERY TIME COMMAND".getBytes();
firstMessage = Unpooled.buffer(req.length);
firstMessage.writeBytes(req);
......
......@@ -12,7 +12,7 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
/**
* Created by shenhongxi on 2018/10/5.
*/
public class TimeServer {
public class HelloServer {
public void bind(int port) throws Exception {
// 配置服务端的NIO线程组
......@@ -41,11 +41,11 @@ public class TimeServer {
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
socketChannel.pipeline().addLast(new TimeServerHandler());
socketChannel.pipeline().addLast(new HelloServerHandler());
}
}
public static void main(String[] args) throws Exception {
new TimeServer().bind(8080);
new HelloServer().bind(8080);
}
}
......@@ -10,7 +10,7 @@ import java.util.Date;
/**
* Created by shenhongxi on 2018/10/5.
*/
public class TimeServerHandler extends ChannelInboundHandlerAdapter {
public class HelloServerHandler extends ChannelInboundHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
ByteBuf buf = (ByteBuf) msg;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册