mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
Fix selective send (#90)
* Move VisionSettingsChangeSubscriber to own class * Use selective sending on simple PSCs * Fix origin context skip logic
This commit is contained in:
@@ -20,7 +20,6 @@ package org.photonvision.server;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.photonvision.common.dataflow.DataChangeDestination;
|
||||
import org.photonvision.common.dataflow.DataChangeSource;
|
||||
import org.photonvision.common.dataflow.DataChangeSubscriber;
|
||||
@@ -31,7 +30,7 @@ import org.photonvision.common.logging.Logger;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
/*
|
||||
* DO NOT use logging in this class. If you do, the logs will recuse forever!
|
||||
* DO NOT use logging in this class. If you do, the logs will recurse forever!
|
||||
*/
|
||||
class UIOutboundSubscriber extends DataChangeSubscriber {
|
||||
Logger logger = new Logger(UIOutboundSubscriber.class, LogGroup.WebServer);
|
||||
@@ -48,25 +47,11 @@ class UIOutboundSubscriber extends DataChangeSubscriber {
|
||||
if (event instanceof OutgoingUIEvent) {
|
||||
var thisEvent = (OutgoingUIEvent) event;
|
||||
try {
|
||||
switch (thisEvent.updateType) {
|
||||
case BROADCAST:
|
||||
{
|
||||
if (event.data instanceof HashMap) {
|
||||
var data = (HashMap) event.data;
|
||||
socketHandler.broadcastMessage(data, null);
|
||||
} else {
|
||||
socketHandler.broadcastMessage(event.data, null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SINGLEUSER:
|
||||
{
|
||||
if (event.data instanceof Pair) {
|
||||
var pair = (SocketHandler.SelectiveBroadcastPair) event.data;
|
||||
socketHandler.broadcastMessage(pair.getLeft(), pair.getRight());
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (event.data instanceof HashMap) {
|
||||
var data = (HashMap) event.data;
|
||||
socketHandler.broadcastMessage(data, thisEvent.originContext);
|
||||
} else {
|
||||
socketHandler.broadcastMessage(event.data, thisEvent.originContext);
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.error("Failed to process outgoing message!", e);
|
||||
|
||||
Reference in New Issue
Block a user