Skip to content

Commit 6c57216

Browse files
author
Peng Hu
committed
消息执行器
1 parent 8dc7b17 commit 6c57216

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

src/main/java/info/xiaomo/gengine/network/client/ClientFuture.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
/**
4747
*
4848
* 从grizzly的 FutureImpl精简而来. </br>
49-
*
50-
* 详情查看 {@link org.glassfish.grizzly.impl.SafeFutureImpl} .
49+
*
5150
* <p/>
5251
* (Based on the JDK {@link java.util.concurrent.FutureTask})
5352
*
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package info.xiaomo.gengine.network.handler;
22

3+
import com.google.protobuf.AbstractMessage;
34
import info.xiaomo.gengine.network.INetworkConsumer;
45
import info.xiaomo.gengine.network.INetworkEventListener;
5-
import io.netty.channel.ChannelHandlerAdapter;
66
import io.netty.channel.ChannelHandlerContext;
7+
import io.netty.channel.SimpleChannelInboundHandler;
78

89
/**
910
* @author xiaomo
10-
* :todo
1111
*/
12-
public class MessageExecutor extends ChannelHandlerAdapter {
12+
public class MessageExecutor extends SimpleChannelInboundHandler<Object> {
1313

14-
private INetworkConsumer consumer;
14+
private final INetworkConsumer consumer;
1515

1616
private final INetworkEventListener listener;
1717

@@ -22,23 +22,23 @@ public MessageExecutor(INetworkConsumer consumer, INetworkEventListener listener
2222
}
2323

2424

25-
2625
@Override
2726
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
2827
listener.onExceptionOccur(ctx, cause);
2928
}
3029

31-
// @Override
32-
// public void channelRead(ChannelHandlerContext ctx, Object msg) {
33-
// consumer.consume((AbstractMessage) msg, ctx.channel());
34-
// }
35-
// @Override
36-
// public void channelActive(ChannelHandlerContext ctx) {
37-
// this.listener.onConnected(ctx);
38-
// }
39-
//
40-
// @Override
41-
// public void channelInactive(ChannelHandlerContext ctx) {
42-
// this.listener.onDisconnected(ctx);
43-
// }
30+
@Override
31+
public void channelRead0(ChannelHandlerContext ctx, Object msg) {
32+
consumer.consume((AbstractMessage) msg, ctx.channel());
33+
}
34+
35+
@Override
36+
public void channelActive(ChannelHandlerContext ctx) {
37+
this.listener.onConnected(ctx);
38+
}
39+
40+
@Override
41+
public void channelInactive(ChannelHandlerContext ctx) {
42+
this.listener.onDisconnected(ctx);
43+
}
4444
}

0 commit comments

Comments
 (0)