fix reconnect

back_recharge
wangyuan 2019-09-19 20:21:06 +08:00
parent 0f229baaa4
commit 7d84edc660
2 changed files with 1 additions and 18 deletions

View File

@ -232,12 +232,8 @@ public class ProtocolsManager implements ProtocolsAbstract {
if(indicationInRedis!=null){
Map<Integer, ISession.IndicationMsg> map= gson.fromJson(indicationInRedis.toString(),type);
for(Map.Entry<Integer,ISession.IndicationMsg> info : map.entrySet()){
Integer msgIndex = info.getKey();
session.writeAndFlush(info.getValue().getMsg());
session.putBackIndicationToMap(msgIndex,info.getValue().getMsg());
if(maxMsgId<msgIndex){
maxMsgId = msgIndex;
}
session.putBackIndicationToMap(maxMsgId++,info.getValue().getMsg());
}
RedisUtil.getInstence().del(key);
}

View File

@ -50,23 +50,10 @@ public class RetrySendIndicationThread extends Thread{
session.setFiveByteBuf(null);
}
ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
boolean send = false;
for(ISession.IndicationMsg indicationMsg : indexToIndication.values()){
long create = indicationMsg.getCreate();
int retryTimes = indicationMsg.getRetryTimes()+1;
if(now-create>retryTimes*300){
if(session.getUid() == 20000739){
Calendar calendar = Calendar.getInstance();
int i = calendar.get(Calendar.MINUTE);
if(i%2==0 && !send){
for(Integer id : indexToIndication.keySet()){
LOGGER.info("indication id={}",id);
}
send = true;
}
}
MessageUtil.retrySendIndication(session,indicationMsg.getMsg());
indicationMsg.setRetryTimes(retryTimes);
}