张延森 vor 5 Jahren
Ursprung
Commit
651dde93fd
1 geänderte Dateien mit 10 neuen und 10 gelöschten Zeilen
  1. 10
    10
      src/main/java/com/huiju/estateagents/websocket/ChatServer.java

+ 10
- 10
src/main/java/com/huiju/estateagents/websocket/ChatServer.java Datei anzeigen

@@ -51,7 +51,7 @@ public class ChatServer {
51 51
         removeSameFromSets(sid);
52 52
         this.session = session;
53 53
         webSocketSet.add(this);
54
-        addOnlineCount();
54
+//        addOnlineCount();
55 55
         this.sid=sid;
56 56
         log.info("有新窗口开始监听: "+sid+" ,当前在线人数为 " + getOnlineCount());
57 57
     }
@@ -119,7 +119,7 @@ public class ChatServer {
119 119
         for(ChatServer c: webSocketSet) {
120 120
             if (sid.equals(c.sid)) {
121 121
                 webSocketSet.remove(c);
122
-                subOnlineCount();
122
+//                subOnlineCount();
123 123
                 log.info("有一连接关闭:"+sid+"!当前在线人数为" + getOnlineCount());
124 124
             }
125 125
         }
@@ -129,7 +129,7 @@ public class ChatServer {
129 129
         for(ChatServer c: webSocketSet) {
130 130
             if (currentSid.equals(c.sid)) {
131 131
                 webSocketSet.remove(c);
132
-                subOnlineCount();
132
+//                subOnlineCount();
133 133
                 log.info("有一连接关闭:"+sid+"!当前在线人数为" + getOnlineCount());
134 134
             }
135 135
         }
@@ -166,16 +166,16 @@ public class ChatServer {
166 166
     }
167 167
 
168 168
     public static synchronized int getOnlineCount() {
169
-        return onlineCount;
169
+        return webSocketSet.size();
170 170
     }
171 171
 
172
-    public static synchronized void addOnlineCount() {
173
-        ChatServer.onlineCount++;
174
-    }
172
+//    public static synchronized void addOnlineCount() {
173
+//        ChatServer.onlineCount++;
174
+//    }
175 175
 
176
-    public static synchronized void subOnlineCount() {
177
-        ChatServer.onlineCount--;
178
-    }
176
+//    public static synchronized void subOnlineCount() {
177
+//        ChatServer.onlineCount--;
178
+//    }
179 179
 
180 180
     public static void setApplicationContext(ApplicationContext applicationContext) {
181 181
         ChatServer.applicationContext = applicationContext;