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){ if(indicationInRedis!=null){
Map<Integer, ISession.IndicationMsg> map= gson.fromJson(indicationInRedis.toString(),type); Map<Integer, ISession.IndicationMsg> map= gson.fromJson(indicationInRedis.toString(),type);
for(Map.Entry<Integer,ISession.IndicationMsg> info : map.entrySet()){ for(Map.Entry<Integer,ISession.IndicationMsg> info : map.entrySet()){
Integer msgIndex = info.getKey();
session.writeAndFlush(info.getValue().getMsg()); session.writeAndFlush(info.getValue().getMsg());
session.putBackIndicationToMap(msgIndex,info.getValue().getMsg()); session.putBackIndicationToMap(maxMsgId++,info.getValue().getMsg());
if(maxMsgId<msgIndex){
maxMsgId = msgIndex;
}
} }
RedisUtil.getInstence().del(key); RedisUtil.getInstence().del(key);
} }

View File

@ -50,23 +50,10 @@ public class RetrySendIndicationThread extends Thread{
session.setFiveByteBuf(null); session.setFiveByteBuf(null);
} }
ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication(); ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
boolean send = false;
for(ISession.IndicationMsg indicationMsg : indexToIndication.values()){ for(ISession.IndicationMsg indicationMsg : indexToIndication.values()){
long create = indicationMsg.getCreate(); long create = indicationMsg.getCreate();
int retryTimes = indicationMsg.getRetryTimes()+1; int retryTimes = indicationMsg.getRetryTimes()+1;
if(now-create>retryTimes*300){ 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()); MessageUtil.retrySendIndication(session,indicationMsg.getMsg());
indicationMsg.setRetryTimes(retryTimes); indicationMsg.setRetryTimes(retryTimes);
} }