context.setClientWorker(this);
context.setApplicationContext(applicationContext);
// 定时发送心跳
ScheduledExecutorService service = Executors.newScheduledThreadPool(2);
service.scheduleAtFixedRate(new Runnable() {
private WorkerHeartBeat heartbeat = new WorkerHeartBeat();
private int failCount = 0;
@Override
public void run() {
try {
if (context.getServerChannel() == null) {
return;
}
ChannelFuture cf = heartbeat.execute(context);
cf.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future)
throws Exception {
if (!future.isSuccess()) {
failCount++;