use of org.openremote.model.simulator.RequestSimulatorState in project openremote by openremote.
the class SimulatorService method configure.
@Override
public void configure() throws Exception {
from(CLIENT_EVENT_TOPIC).routeId("FromClientSimulatorRequests").filter(body().isInstanceOf(RequestSimulatorState.class)).process(exchange -> {
RequestSimulatorState event = exchange.getIn().getBody(RequestSimulatorState.class);
LOG.fine("Handling from client: " + event);
String sessionKey = getSessionKey(exchange);
AuthContext authContext = exchange.getIn().getHeader(Constants.AUTH_CONTEXT, AuthContext.class);
// Superuser can get all
if (!authContext.isSuperUser())
return;
for (AttributeRef protocolConfiguration : event.getConfigurations()) {
publishSimulatorState(sessionKey, protocolConfiguration);
}
});
from(CLIENT_EVENT_TOPIC).routeId("FromClientSimulatorState").filter(body().isInstanceOf(SimulatorState.class)).process(exchange -> {
SimulatorState event = exchange.getIn().getBody(SimulatorState.class);
LOG.fine("Handling from client: " + event);
AuthContext authContext = exchange.getIn().getHeader(Constants.AUTH_CONTEXT, AuthContext.class);
// Superuser can get all
if (!authContext.isSuperUser())
return;
// TODO Should realm admins be able to work with simulators in their tenant?
simulatorProtocol.updateSimulatorState(event);
});
}
use of org.openremote.model.simulator.RequestSimulatorState in project openremote by openremote.
the class Simulator method createSimulator.
protected void createSimulator() {
eventRegistration = environment.getEventBus().register(SimulatorState.class, simulatorState -> {
if (!simulatorState.getProtocolConfigurationRef().equals(protocolConfiguration))
return;
this.simulatorState = simulatorState;
writeView();
});
environment.getEventService().dispatch(new RequestSimulatorState(protocolConfiguration));
onCreate.run();
}
Aggregations