Рефакторинг
This commit is contained in:
@@ -10,7 +10,7 @@ import ru.serega6531.packmate.utils.Bytes;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
public class PatternMatcher {
|
class PatternMatcher {
|
||||||
|
|
||||||
private static final Map<String, java.util.regex.Pattern> compiledPatterns = new HashMap<>();
|
private static final Map<String, java.util.regex.Pattern> compiledPatterns = new HashMap<>();
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class PatternMatcher {
|
|||||||
|
|
||||||
startSearch = end + 1;
|
startSearch = end + 1;
|
||||||
}
|
}
|
||||||
} else { // SUBBYTES
|
} else if (pattern.getSearchType() == PatternSearchType.SUBBYTES) {
|
||||||
int startSearch = 0;
|
int startSearch = 0;
|
||||||
final byte[] value = Hex.decode(pattern.getValue());
|
final byte[] value = Hex.decode(pattern.getValue());
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class ServicesService {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<CtfService> findByPort(int port) {
|
private Optional<CtfService> findByPort(int port) {
|
||||||
return Optional.ofNullable(services.get(port));
|
return Optional.ofNullable(services.get(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ public class StreamService {
|
|||||||
return foundPatterns;
|
return foundPatterns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stream save(Stream stream) {
|
private Stream save(Stream stream) {
|
||||||
Stream saved;
|
Stream saved;
|
||||||
if (stream.getId() == null) {
|
if (stream.getId() == null) {
|
||||||
saved = repository.save(stream);
|
saved = repository.save(stream);
|
||||||
@@ -167,6 +167,7 @@ public class StreamService {
|
|||||||
repository.setFavorite(id, favorite);
|
repository.setFavorite(id, favorite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ConstantConditions")
|
||||||
public List<Stream> findAll(Pagination pagination, Optional<Integer> service, boolean onlyFavorites) {
|
public List<Stream> findAll(Pagination pagination, Optional<Integer> service, boolean onlyFavorites) {
|
||||||
PageRequest page = PageRequest.of(0, pagination.getPageSize(), pagination.getDirection(), "id");
|
PageRequest page = PageRequest.of(0, pagination.getPageSize(), pagination.getDirection(), "id");
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,13 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class StreamSubscriptionService {
|
public class StreamSubscriptionService {
|
||||||
|
|
||||||
private List<WebSocketSession> subscribers = Collections.synchronizedList(new ArrayList<>());
|
private final List<WebSocketSession> subscribers = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
@@ -30,12 +31,12 @@ public class StreamSubscriptionService {
|
|||||||
|
|
||||||
public void addSubscriber(WebSocketSession session) {
|
public void addSubscriber(WebSocketSession session) {
|
||||||
subscribers.add(session);
|
subscribers.add(session);
|
||||||
log.info("Подписан пользователь {}", session.getRemoteAddress().getHostName());
|
log.info("Подписан пользователь {}", Objects.requireNonNull(session.getRemoteAddress()).getHostName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSubscriber(WebSocketSession session) {
|
public void removeSubscriber(WebSocketSession session) {
|
||||||
subscribers.remove(session);
|
subscribers.remove(session);
|
||||||
log.info("Отписан пользователь {}", session.getRemoteAddress().getHostName());
|
log.info("Отписан пользователь {}", Objects.requireNonNull(session.getRemoteAddress()).getHostName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcast(SubscriptionMessage message) {
|
public void broadcast(SubscriptionMessage message) {
|
||||||
|
|||||||
Reference in New Issue
Block a user