master
剑器近 2021-06-29 14:48:37 +08:00
parent 244ca3483f
commit 195d636b20
1 changed files with 18 additions and 18 deletions

View File

@ -58,20 +58,6 @@ public class Session {
return session;
}
public int nextSerialNo() {
int current;
int next;
do {
current = serialNo.get();
next = current > 0xffff ? 0 : current;
} while (!serialNo.compareAndSet(current, next + 1));
return next;
}
public boolean isRegistered() {
return sessionId != null;
}
/**
* SessionManager
*/
@ -88,6 +74,10 @@ public class Session {
sessionManager.add(this);
}
public boolean isRegistered() {
return sessionId != null;
}
public String getId() {
return sessionId;
}
@ -150,6 +140,16 @@ public class Session {
sessionListener.sessionCreated(this);
}
public int nextSerialNo() {
int current;
int next;
do {
current = serialNo.get();
next = current > 0xffff ? 0 : current;
} while (!serialNo.compareAndSet(current, next + 1));
return next;
}
public void invalidate() {
channel.close();
callSessionDestroyedListener();
@ -158,10 +158,10 @@ public class Session {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(66);
sb.append("[ip=").append(channel.remoteAddress());
sb.append(", sid=").append(sessionId);
sb.append(", cid=").append(clientId);
sb.append(']');
sb.append("{sid=").append(sessionId);
sb.append(",cid=").append(clientId);
sb.append(",ip=").append(channel.remoteAddress());
sb.append('}');
return sb.toString();
}