[Minor] Fix broken state notification
This commit is contained in:
parent
f2e1ff1152
commit
3d15a45744
|
@ -267,7 +267,7 @@ public class PlcGwClientHandler extends StrolchComponent implements GlobalPlcLis
|
||||||
if (lastUpdate > TimeUnit.HOURS.toMillis(1)) {
|
if (lastUpdate > TimeUnit.HOURS.toMillis(1)) {
|
||||||
logger.info("Sending system state to server...");
|
logger.info("Sending system state to server...");
|
||||||
JsonObject stateJ = new JsonObject();
|
JsonObject stateJ = new JsonObject();
|
||||||
stateJ.addProperty(PARAM_MESSAGE_TYPE, MSG_TYPE_AUTHENTICATION);
|
stateJ.addProperty(PARAM_MESSAGE_TYPE, MSG_TYPE_STATE_NOTIFICATION);
|
||||||
stateJ.addProperty(PARAM_PLC_ID, this.plcId);
|
stateJ.addProperty(PARAM_PLC_ID, this.plcId);
|
||||||
stateJ.add(PARAM_IP_ADDRESSES, getIpAddresses());
|
stateJ.add(PARAM_IP_ADDRESSES, getIpAddresses());
|
||||||
stateJ.add(PARAM_VERSIONS, getVersions());
|
stateJ.add(PARAM_VERSIONS, getVersions());
|
||||||
|
|
|
@ -20,10 +20,10 @@ import com.google.gson.JsonParser;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
import li.strolch.agent.api.ComponentContainer;
|
import li.strolch.agent.api.ComponentContainer;
|
||||||
import li.strolch.agent.api.StrolchComponent;
|
import li.strolch.agent.api.StrolchComponent;
|
||||||
import li.strolch.model.log.LogMessage;
|
|
||||||
import li.strolch.model.log.LogMessageState;
|
|
||||||
import li.strolch.handler.operationslog.OperationsLog;
|
import li.strolch.handler.operationslog.OperationsLog;
|
||||||
import li.strolch.model.Locator;
|
import li.strolch.model.Locator;
|
||||||
|
import li.strolch.model.log.LogMessage;
|
||||||
|
import li.strolch.model.log.LogMessageState;
|
||||||
import li.strolch.plc.model.*;
|
import li.strolch.plc.model.*;
|
||||||
import li.strolch.privilege.base.NotAuthenticatedException;
|
import li.strolch.privilege.base.NotAuthenticatedException;
|
||||||
import li.strolch.privilege.model.Certificate;
|
import li.strolch.privilege.model.Certificate;
|
||||||
|
@ -296,6 +296,12 @@ public class PlcGwServerHandler extends StrolchComponent {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case MSG_TYPE_STATE_NOTIFICATION: {
|
||||||
|
PlcSession plcSession = assertPlcAuthed(plcId, session.getId());
|
||||||
|
handleStateMsg(plcSession, jsonObject);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_TYPE_MESSAGE: {
|
case MSG_TYPE_MESSAGE: {
|
||||||
assertPlcAuthed(plcId, session.getId());
|
assertPlcAuthed(plcId, session.getId());
|
||||||
handleMessage(jsonObject);
|
handleMessage(jsonObject);
|
||||||
|
@ -351,6 +357,7 @@ public class PlcGwServerHandler extends StrolchComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<PlcNotificationListener> listeners;
|
List<PlcNotificationListener> listeners;
|
||||||
|
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||||
synchronized (plcListeners) {
|
synchronized (plcListeners) {
|
||||||
listeners = plcListeners.getList(addressKey);
|
listeners = plcListeners.getList(addressKey);
|
||||||
if (listeners == null) {
|
if (listeners == null) {
|
||||||
|
@ -433,6 +440,10 @@ public class PlcGwServerHandler extends StrolchComponent {
|
||||||
this.plcStateHandler.handlePlcState(plcSession, ConnectionState.Connected, "", authJ);
|
this.plcStateHandler.handlePlcState(plcSession, ConnectionState.Connected, "", authJ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleStateMsg(PlcSession plcSession, JsonObject stateMsgJ) {
|
||||||
|
this.plcStateHandler.handlePlcState(plcSession, ConnectionState.Connected, "", stateMsgJ);
|
||||||
|
}
|
||||||
|
|
||||||
private void sendAuthResponse(PlcSession plcSession, JsonObject jsonObject) {
|
private void sendAuthResponse(PlcSession plcSession, JsonObject jsonObject) {
|
||||||
try {
|
try {
|
||||||
String data = jsonObject.toString();
|
String data = jsonObject.toString();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import li.strolch.rest.RestfulStrolchComponent;
|
||||||
@ServerEndpoint("/websocket/strolch/plc")
|
@ServerEndpoint("/websocket/strolch/plc")
|
||||||
public class PlcServerWebSocketEndpoint {
|
public class PlcServerWebSocketEndpoint {
|
||||||
|
|
||||||
private PlcGwServerHandler serverHandler;
|
private final PlcGwServerHandler serverHandler;
|
||||||
|
|
||||||
public PlcServerWebSocketEndpoint() {
|
public PlcServerWebSocketEndpoint() {
|
||||||
this.serverHandler = RestfulStrolchComponent.getInstance().getComponent(PlcGwServerHandler.class);
|
this.serverHandler = RestfulStrolchComponent.getInstance().getComponent(PlcGwServerHandler.class);
|
||||||
|
|
Loading…
Reference in New Issue