reconnect
parent
bdc84eb2fc
commit
eb6cf6f62b
|
@ -20,6 +20,7 @@ import com.ljsd.jieling.logic.dao.UserManager;
|
|||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.netty.cocdex.Tea;
|
||||
import com.ljsd.jieling.netty.handler.GameMessageHandler;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocol.ProtocolsAbstract;
|
||||
|
@ -27,6 +28,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|||
import com.ljsd.jieling.session.GameSession;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.ljsd.jieling.util.StringUtil;
|
||||
import com.ljsd.jieling.util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -233,14 +235,23 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
Map<Integer, ISession.IndicationMsg> map= gson.fromJson(indicationInRedis.toString(),type);
|
||||
for(Map.Entry<Integer,ISession.IndicationMsg> info : map.entrySet()){
|
||||
session.writeAndFlush(info.getValue().getMsg());
|
||||
session.putBackIndicationToMap(maxMsgId++,info.getValue().getMsg());
|
||||
session.putBackIndicationToMap(info.getKey(),info.getValue().getMsg());
|
||||
if(info.getKey()>maxMsgId){
|
||||
maxMsgId = info.getKey();
|
||||
}
|
||||
}
|
||||
RedisUtil.getInstence().del(key);
|
||||
RedisUtil.getInstence().del(key);
|
||||
}
|
||||
key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
type = new TypeToken<Map<Integer, byte[]>>(){}.getType();
|
||||
Object responsInRedis = RedisUtil.getInstence().get(key);
|
||||
session.setFiveReady(1);
|
||||
String indicationIndexInRedisKey = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
|
||||
String indicationIndexInRedis =(String) RedisUtil.getInstence().get(indicationIndexInRedisKey);
|
||||
if(!StringUtil.isEmpty(indicationIndexInRedis)){
|
||||
maxMsgId= Integer.parseInt(indicationIndexInRedis);
|
||||
}
|
||||
|
||||
session.updateIndicationIndex(maxMsgId);
|
||||
if(responsInRedis!=null){
|
||||
Map<Integer, byte[]> response = gson.fromJson(responsInRedis.toString(), type);
|
||||
|
@ -391,12 +402,15 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
|
||||
private void backUpMsgToRedis(ISession session){
|
||||
ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
|
||||
LOGGER.info("the uid={} offline.the indication size={}",session.getUid(),indexToIndication.size());
|
||||
if(!indexToIndication.isEmpty() ){
|
||||
String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
|
||||
RedisUtil.getInstence().set(key,gson.toJson(indexToIndication));
|
||||
}
|
||||
String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
|
||||
RedisUtil.getInstence().set(key,String.valueOf(session.getIndicationIndex()));
|
||||
|
||||
String key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
RedisUtil.getInstence().set(key,gson.toJson(session.getIndexToMessage()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue