...
|
...
|
@@ -15,7 +15,7 @@ import java.util.concurrent.CopyOnWriteArraySet; |
|
|
|
|
|
@ServerEndpoint(value = "/log")
|
|
|
@Component
|
|
|
public class Log {
|
|
|
public class LogWebsockController {
|
|
|
private Process process;
|
|
|
private InputStream inputStream;
|
|
|
//与某个客户端的连接会话,需要通过它来给客户端发送数据
|
...
|
...
|
@@ -24,7 +24,7 @@ public class Log { |
|
|
//静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
|
|
|
private static int onlineCount = 0;
|
|
|
//concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
|
|
|
private static CopyOnWriteArraySet<Log> webSocketSet = new CopyOnWriteArraySet<Log>();
|
|
|
private static CopyOnWriteArraySet<LogWebsockController> webSocketSet = new CopyOnWriteArraySet<LogWebsockController>();
|
|
|
|
|
|
|
|
|
@OnOpen
|
...
|
...
|
@@ -67,7 +67,7 @@ public class Log { |
|
|
}
|
|
|
|
|
|
public static synchronized void addOnlineCount() {
|
|
|
Log.onlineCount++;
|
|
|
LogWebsockController.onlineCount++;
|
|
|
}
|
|
|
public static synchronized int getOnlineCount() {
|
|
|
return onlineCount;
|
...
|
...
|
|