Search in sources :

Example 6 with Role

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));
    }
}
Also used : Role(io.openems.common.session.Role)

Example 7 with 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());
        }
    }
}
Also used : Role(io.openems.common.session.Role) JsonObject(com.google.gson.JsonObject) OpenemsException(io.openems.common.exceptions.OpenemsException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

Role (io.openems.common.session.Role)7 JsonObject (com.google.gson.JsonObject)6 OpenemsException (io.openems.common.exceptions.OpenemsException)4 User (io.openems.backend.metadata.api.User)3 JsonArray (com.google.gson.JsonArray)2 Edge (io.openems.backend.metadata.api.Edge)2 IsThingMap (io.openems.api.controller.IsThingMap)1 DeviceNature (io.openems.api.device.nature.DeviceNature)1 WriteJsonObject (io.openems.core.utilities.api.WriteJsonObject)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 NoSuchElementException (java.util.NoSuchElementException)1 UUID (java.util.UUID)1