use of io.openems.common.session.Role in project openems by OpenEMS.
the class EdgeWebsocketHandler method setUser.
public synchronized void setUser(Optional<User> userOpt) {
this.userOpt = userOpt;
if (this.currentDataWorkerOpt.isPresent()) {
this.currentDataWorkerOpt.get().dispose();
this.currentDataWorkerOpt = Optional.empty();
}
if (userOpt.isPresent()) {
Role role = userOpt.get().getRole();
this.currentDataWorkerOpt = Optional.of(new EdgeCurrentDataWorker(this, websocket, role));
}
}
use of io.openems.common.session.Role in project openems by OpenEMS.
the class WebsocketApiServer method onConfigUpdate.
public void onConfigUpdate() {
for (UiEdgeWebsocketHandler handler : this.handlers.values()) {
try {
Role role = handler.getUserOpt().get().getRole();
JsonObject j = DefaultMessages.configQueryReply(new JsonObject(), Config.getInstance().getJson(ConfigFormat.OPENEMS_UI, role, DEFAULT_CONFIG_LANGUAGE));
handler.send(j);
} catch (OpenemsException | NoSuchElementException e) {
log.warn(e.getMessage());
}
}
}
Aggregations