回退多注释的

back_recharge
zhangshanxue 2019-11-26 15:55:29 +08:00
parent 8c16c9d9c5
commit ff0279bddc
3 changed files with 33 additions and 12 deletions

View File

@ -1,18 +1,20 @@
package com.ljsd.jieling.logic;
import com.ljsd.jieling.network.session.ISession;
import org.springframework.data.redis.support.collections.DefaultRedisMap;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class OnlineUserManager {
public static Map<Integer, ISession> sessionMap = new ConcurrentHashMap<>();
public static void userOnline(int uid, ISession session) {
sessionMap.put(uid, session);
}
public static Map<Integer, ISession> sessionMap = new DefinaMap<>();
public static void userOffline(int uid) {
sessionMap.remove(uid);
@ -44,4 +46,22 @@ public class OnlineUserManager {
return sessionMap.containsKey(uid);
}
static class DefinaMap<k,v> extends HashMap<k,v>{
@Override
public boolean remove(Object key, Object value) {
return super.remove(key, value);
}
@Override
public v put(k key, v value) {
return super.put(key, value);
}
@Override
public void clear() {
super.clear();
}
}
}

View File

@ -244,15 +244,15 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
int index = packetNetData.getIndex();
if (iSession.getIndex() >= index) {
byte[] message = iSession.getCacheMessage(index);
// if (message == null) {
// //TODO error
// LOGGER.info("the uid={},the msg={} is processing,the index={},the sessionIndex={}", iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()), index, iSession.getIndex());
// return 1;
// } else {
// LOGGER.info("the uid={},the msg={} reback", iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
// iSession.writeAndFlush(message);
// return 1;
// }
if (message == null) {
//TODO error
LOGGER.info("the uid={},the msg={} is processing,the index={},the sessionIndex={}", iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()), index, iSession.getIndex());
return 1;
} else {
LOGGER.info("the uid={},the msg={} reback", iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
iSession.writeAndFlush(message);
return 1;
}
} else {
iSession.setIndex(index);
iSession.setLoginTime(System.currentTimeMillis());
@ -362,6 +362,7 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
return new ISession(channel, handler);
}
private void processUserOfflineData(User user,ISession session){
try {
GuildLogic.updateMyPos(user);

View File

@ -41,7 +41,7 @@ public class RetrySendIndicationThread extends Thread{
long now = TimeUtils.now();
Set<Integer> removeIds = new HashSet<>();
for(ISession session : sessionMap.values()){
if(session.getChannel().isClosed()&&session.getChannel().isConnected()){
if(!session.getChannel().isClosed()&&session.getChannel().isConnected()){
// ChannelHandlerContext localCtx = session.getCtx();