张延森 5 jaren geleden
bovenliggende
commit
651dde93fd
1 gewijzigde bestanden met toevoegingen van 10 en 10 verwijderingen
  1. 10
    10
      src/main/java/com/huiju/estateagents/websocket/ChatServer.java

+ 10
- 10
src/main/java/com/huiju/estateagents/websocket/ChatServer.java Bestand weergeven

51
         removeSameFromSets(sid);
51
         removeSameFromSets(sid);
52
         this.session = session;
52
         this.session = session;
53
         webSocketSet.add(this);
53
         webSocketSet.add(this);
54
-        addOnlineCount();
54
+//        addOnlineCount();
55
         this.sid=sid;
55
         this.sid=sid;
56
         log.info("有新窗口开始监听: "+sid+" ,当前在线人数为 " + getOnlineCount());
56
         log.info("有新窗口开始监听: "+sid+" ,当前在线人数为 " + getOnlineCount());
57
     }
57
     }
119
         for(ChatServer c: webSocketSet) {
119
         for(ChatServer c: webSocketSet) {
120
             if (sid.equals(c.sid)) {
120
             if (sid.equals(c.sid)) {
121
                 webSocketSet.remove(c);
121
                 webSocketSet.remove(c);
122
-                subOnlineCount();
122
+//                subOnlineCount();
123
                 log.info("有一连接关闭:"+sid+"!当前在线人数为" + getOnlineCount());
123
                 log.info("有一连接关闭:"+sid+"!当前在线人数为" + getOnlineCount());
124
             }
124
             }
125
         }
125
         }
129
         for(ChatServer c: webSocketSet) {
129
         for(ChatServer c: webSocketSet) {
130
             if (currentSid.equals(c.sid)) {
130
             if (currentSid.equals(c.sid)) {
131
                 webSocketSet.remove(c);
131
                 webSocketSet.remove(c);
132
-                subOnlineCount();
132
+//                subOnlineCount();
133
                 log.info("有一连接关闭:"+sid+"!当前在线人数为" + getOnlineCount());
133
                 log.info("有一连接关闭:"+sid+"!当前在线人数为" + getOnlineCount());
134
             }
134
             }
135
         }
135
         }
166
     }
166
     }
167
 
167
 
168
     public static synchronized int getOnlineCount() {
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
     public static void setApplicationContext(ApplicationContext applicationContext) {
180
     public static void setApplicationContext(ApplicationContext applicationContext) {
181
         ChatServer.applicationContext = applicationContext;
181
         ChatServer.applicationContext = applicationContext;