back_recharge
zhangshanxue 2019-09-19 21:16:57 +08:00
commit e9d0b2d27f
2 changed files with 17 additions and 9 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);
}
@ -257,6 +253,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
}
}
LOGGER.info("the uid={} reconnect,the maxid={} ",session.getUid(),maxMsgId);
MessageUtil.sendMessageWithoutBack(session,1, MessageTypeProto.MessageType.RECONNECT_RESPONSE_VALUE,null,true);
}

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.thread.task;
import com.google.gson.Gson;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
@ -8,10 +9,7 @@ import com.ljsd.jieling.util.TimeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class RetrySendIndicationThread extends Thread{
@ -52,10 +50,23 @@ 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);
}