private synchronized void stop() { if (stat == Stat.DEC || stat == Stat.READY) { logger.warn("aleady stoped"); return; } stat = Stat.DEC; sendStop(); }
private synchronized void delWsClient(WsClientHandler wsClientHandler, boolean isFail) { clients.remove(wsClientHandler); wsClientHandler.unref(); int size = clients.size(); if (isFail) { failCount++; if (failCount >= maxFailCount) { publish(size, failCount, false); stop(); return; } } switch (stat) { case INC: addWsClient(); break; case DEC: if ((size % 100) == 0) { publish(size, failCount, false); } sendStop(); break; } }