From 195d636b20b23606cf85ae8d679a37884cfdb61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=89=91=E5=99=A8=E8=BF=91?= Date: Tue, 29 Jun 2021 14:48:37 +0800 Subject: [PATCH] update --- .../yezhihao/netmc/session/Session.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/io/github/yezhihao/netmc/session/Session.java b/src/main/java/io/github/yezhihao/netmc/session/Session.java index 9327fe0..681527b 100644 --- a/src/main/java/io/github/yezhihao/netmc/session/Session.java +++ b/src/main/java/io/github/yezhihao/netmc/session/Session.java @@ -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(); }