Skip to content

Commit

Permalink
#约约跨城 #2.3.1 #增加代码注释说明
Browse files Browse the repository at this point in the history
  • Loading branch information
JMCuixy committed Sep 4, 2018
1 parent 4d58e6c commit d8a19b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import io.netty.handler.codec.LineBasedFrameDecoder;

/**
* Created by XiuYin.Cui on 2018/8/26.
* 传入数据流是一系列的帧,每个帧都由换行符(\n)分隔;
* 每个帧都由一系列的元素组成,每个元素都由单个空格字符分隔;
* 一个帧的内容代表一个命令,定义为一个命令名称后跟着数目可变的参数。
*/
public class CmdHandlerInitializer extends ChannelInitializer<Channel> {

Expand All @@ -25,7 +27,9 @@ protected void initChannel(Channel ch) throws Exception {
* Cmd POJO
*/
public static final class Cmd {
// 表示命令
private final ByteBuf name;
//表示可变的参数
private final ByteBuf args;

public Cmd(ByteBuf name, ByteBuf args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
public class LengthBasedInitializer extends ChannelInitializer<Channel> {


@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(
// 将提取到的桢转发给下一个Channelhandler
new LineBasedFrameDecoder(64 * 1024),
// 添加 FrameHandler 以接收帧
new FrameHandler()
);
}


public static final class FrameHandler extends SimpleChannelInboundHandler<ByteBuf> {

@Override
Expand Down

0 comments on commit d8a19b7

Please sign in to comment.