Skip to content

Commit

Permalink
增加用户绑定和路由踢人
Browse files Browse the repository at this point in the history
  • Loading branch information
ohun committed Dec 30, 2015
1 parent 2575c35 commit d0f9a65
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Expand Up @@ -50,7 +50,7 @@ public void handle(HandShakeMessage message) {


//4.生成可复用session, 用于快速重连 //4.生成可复用session, 用于快速重连
ReusableSession session = ReusableSessionManager.INSTANCE.genSession(context); ReusableSession session = ReusableSessionManager.INSTANCE.genSession(context);
ReusableSessionManager.INSTANCE.saveSession(session); ReusableSessionManager.INSTANCE.cacheSession(session);


//5.响应握手成功消息 //5.响应握手成功消息
HandshakeSuccessMessage HandshakeSuccessMessage
Expand Down
Expand Up @@ -12,15 +12,15 @@
public final class ReusableSessionManager { public final class ReusableSessionManager {
public static final ReusableSessionManager INSTANCE = new ReusableSessionManager(); public static final ReusableSessionManager INSTANCE = new ReusableSessionManager();
private static final int EXPIRE_TIME = 24 * 60 * 60 * 1000; private static final int EXPIRE_TIME = 24 * 60 * 60 * 1000;
private final Map<String, ReusableSession> tokenCache = new ConcurrentHashMap<String, ReusableSession>(); private final Map<String, ReusableSession> sessionCache = new ConcurrentHashMap<String, ReusableSession>();


public boolean saveSession(ReusableSession session) { public boolean cacheSession(ReusableSession session) {
tokenCache.put(session.sessionId, session); sessionCache.put(session.sessionId, session);
return true; return true;
} }


public ReusableSession getSession(String sessionId) { public ReusableSession getSession(String sessionId) {
return tokenCache.get(sessionId); return sessionCache.get(sessionId);
} }


public ReusableSession genSession(SessionContext info) { public ReusableSession genSession(SessionContext info) {
Expand Down

0 comments on commit d0f9a65

Please sign in to comment.