Class UiWebsocketImpl
java.lang.Object
io.openems.backend.common.component.AbstractOpenemsBackendComponent
io.openems.backend.uiwebsocket.impl.UiWebsocketImpl
- All Implemented Interfaces:
DebugLoggable
,UiWebsocket
,org.osgi.service.event.EventHandler
public class UiWebsocketImpl
extends AbstractOpenemsBackendComponent
implements UiWebsocket, org.osgi.service.event.EventHandler, DebugLoggable
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected EdgeWebsocket
protected JsonRpcRequestHandler
protected Metadata
protected WebsocketServer
protected TimedataManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected User
assertUser
(WsData wsData, AbstractJsonrpcRequest request) Gets the authenticated User or throws an Exception if User is not authenticated.debugLog()
Gets some output that is suitable for a continuous Debug log.Gets some output that is suitable for a debug metrics to write down asTimedata
.getId()
void
handleEvent
(org.osgi.service.event.Event event) protected void
Log an error message including the Component ID.protected void
Log an info message including the Component ID.protected void
Log a warn message including the Component ID.void
send
(UUID websocketId, JsonrpcNotification notification) Send a JSON-RPC Notification to a UI session.send
(UUID websocketId, JsonrpcRequest request) Send a JSON-RPC Request to a UI session via WebSocket and expect a JSON-RPC Response.void
sendBroadcast
(String edgeId, JsonrpcNotification notification) Send a JSON-RPC Notification broadcast to all UI sessions with a given Edge-ID.void
sendSubscribedChannels
(String edgeId, EdgeCache edgeCache) Sends the subscribed Channels to the UI session.
-
Field Details
-
server
-
jsonRpcRequestHandler
-
metadata
-
edgeWebsocket
-
timedataManager
-
-
Constructor Details
-
UiWebsocketImpl
public UiWebsocketImpl()
-
-
Method Details
-
logInfo
Description copied from class:AbstractOpenemsBackendComponent
Log an info message including the Component ID.- Overrides:
logInfo
in classAbstractOpenemsBackendComponent
- Parameters:
log
- the Logger that is used for writing the logmessage
- the Info-message
-
logWarn
Description copied from class:AbstractOpenemsBackendComponent
Log a warn message including the Component ID.- Overrides:
logWarn
in classAbstractOpenemsBackendComponent
- Parameters:
log
- the Logger that is used for writing the logmessage
- the Warn-message
-
logError
Description copied from class:AbstractOpenemsBackendComponent
Log an error message including the Component ID.- Overrides:
logError
in classAbstractOpenemsBackendComponent
- Parameters:
log
- the Logger that is used for writing the logmessage
- the Error-message
-
send
public void send(UUID websocketId, JsonrpcNotification notification) throws OpenemsError.OpenemsNamedException Description copied from interface:UiWebsocket
Send a JSON-RPC Notification to a UI session.- Specified by:
send
in interfaceUiWebsocket
- Parameters:
websocketId
- the id of the UI websocket connectionnotification
- the JsonrpcNotification- Throws:
OpenemsError.OpenemsNamedException
- on error
-
send
public CompletableFuture<JsonrpcResponseSuccess> send(UUID websocketId, JsonrpcRequest request) throws OpenemsError.OpenemsNamedException Description copied from interface:UiWebsocket
Send a JSON-RPC Request to a UI session via WebSocket and expect a JSON-RPC Response.- Specified by:
send
in interfaceUiWebsocket
- Parameters:
websocketId
- the id of the UI websocket connectionrequest
- the JsonrpcRequest- Returns:
- the JSON-RPC Success Response Future
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
sendBroadcast
public void sendBroadcast(String edgeId, JsonrpcNotification notification) throws OpenemsError.OpenemsNamedException Description copied from interface:UiWebsocket
Send a JSON-RPC Notification broadcast to all UI sessions with a given Edge-ID.- Specified by:
sendBroadcast
in interfaceUiWebsocket
- Parameters:
edgeId
- the Edge-IDnotification
- the JsonrpcNotification- Throws:
OpenemsError.OpenemsNamedException
- on error
-
handleEvent
public void handleEvent(org.osgi.service.event.Event event) - Specified by:
handleEvent
in interfaceorg.osgi.service.event.EventHandler
-
sendSubscribedChannels
Description copied from interface:UiWebsocket
Sends the subscribed Channels to the UI session.- Specified by:
sendSubscribedChannels
in interfaceUiWebsocket
- Parameters:
edgeId
- the Edge-IDedgeCache
- theEdgeCache
for the Edge-ID
-
assertUser
protected User assertUser(WsData wsData, AbstractJsonrpcRequest request) throws OpenemsError.OpenemsNamedException Gets the authenticated User or throws an Exception if User is not authenticated.- Parameters:
wsData
- the WebSocket attachmentrequest
- theAbstractJsonrpcRequest
- Returns:
- the
User
- Throws:
OpenemsError.OpenemsNamedException
- if User is not authenticated
-
getId
-
debugLog
Description copied from interface:DebugLoggable
Gets some output that is suitable for a continuous Debug log.- Specified by:
debugLog
in interfaceDebugLoggable
- Returns:
- the debug log output; null for no log
-
debugMetrics
Description copied from interface:DebugLoggable
Gets some output that is suitable for a debug metrics to write down asTimedata
.- Specified by:
debugMetrics
in interfaceDebugLoggable
- Returns:
- the key value entries to write down; null or emptyMap for no metrics
-