mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
 JDK 11 References https://github.com/search?q=org%3APhotonVision+jdk-11&type=code JDK 17 References https://github.com/search?q=org%3APhotonVision+jdk-17&type=code TODO List (things we might need to update in other repos): - []ab5fa98d72/photonvision/src/modules/photonvision/start_chroot_script (L29)- []7f8d225445/stage2/01-sys-tweaks/00-packages (L34)- []ab5fa98d72/photonvision/src/modules/photonvision/install.sh (L11)- []a4e7ecb6e3/Makefile (L14)Closes https://github.com/PhotonVision/photonvision/pull/1069 --------- Signed-off-by: Jade Turner <spacey-sooty@proton.me> Co-authored-by: Jade <spacey-sooty@proton.me>
57 lines
2.5 KiB
Java
57 lines
2.5 KiB
Java
/*
|
|
* Copyright (C) Photon Vision.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package org.photonvision.server;
|
|
|
|
import java.util.Collections;
|
|
import org.photonvision.common.configuration.ConfigManager;
|
|
import org.photonvision.common.dataflow.DataChangeDestination;
|
|
import org.photonvision.common.dataflow.DataChangeService;
|
|
import org.photonvision.common.dataflow.DataChangeSource;
|
|
import org.photonvision.common.dataflow.DataChangeSubscriber;
|
|
import org.photonvision.common.dataflow.events.DataChangeEvent;
|
|
import org.photonvision.common.dataflow.events.IncomingWebSocketEvent;
|
|
import org.photonvision.common.dataflow.events.OutgoingUIEvent;
|
|
import org.photonvision.common.dataflow.networktables.NetworkTablesManager;
|
|
import org.photonvision.common.dataflow.websocket.UIPhotonConfiguration;
|
|
import org.photonvision.common.logging.Logger;
|
|
|
|
public class UIInboundSubscriber extends DataChangeSubscriber {
|
|
public UIInboundSubscriber() {
|
|
super(
|
|
Collections.singletonList(DataChangeSource.DCS_WEBSOCKET),
|
|
Collections.singletonList(DataChangeDestination.DCD_GENSETTINGS));
|
|
}
|
|
|
|
@Override
|
|
public void onDataChangeEvent(DataChangeEvent<?> event) {
|
|
if (event instanceof IncomingWebSocketEvent incomingWSEvent) {
|
|
if (incomingWSEvent.propertyName.equals("userConnected")
|
|
|| incomingWSEvent.propertyName.equals("sendFullSettings")) {
|
|
// Send full settings
|
|
var settings =
|
|
UIPhotonConfiguration.programStateToUi(ConfigManager.getInstance().getConfig());
|
|
var message =
|
|
new OutgoingUIEvent<>("fullsettings", settings, incomingWSEvent.originContext);
|
|
DataChangeService.getInstance().publishEvent(message);
|
|
Logger.sendConnectedBacklog();
|
|
NetworkTablesManager.getInstance().broadcastConnectedStatus();
|
|
}
|
|
}
|
|
}
|
|
}
|