Class UiWebsocketImpl
- java.lang.Object
-
- io.openems.backend.common.component.AbstractOpenemsBackendComponent
-
- io.openems.backend.uiwebsocket.impl.UiWebsocketImpl
-
- All Implemented Interfaces:
UiWebsocket
,org.osgi.service.event.EventHandler
public class UiWebsocketImpl extends AbstractOpenemsBackendComponent implements UiWebsocket, org.osgi.service.event.EventHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected EdgeWebsocket
edgeWebsocket
protected JsonRpcRequestHandler
jsonRpcRequestHandler
protected Metadata
metadata
protected WebsocketServer
server
protected TimedataManager
timedataManager
-
Constructor Summary
Constructors Constructor Description UiWebsocketImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description User
assertUser(WsData wsData, AbstractJsonrpcRequest request)
Gets the authenticated User or throws an Exception if User is not authenticated.void
handleEvent(org.osgi.service.event.Event event)
protected void
logError(org.slf4j.Logger log, java.lang.String message)
Log an error message including the Component ID.protected void
logInfo(org.slf4j.Logger log, java.lang.String message)
Log an info message including the Component ID.protected void
logWarn(org.slf4j.Logger log, java.lang.String message)
Log a warn message including the Component ID.void
send(java.lang.String token, JsonrpcNotification notification)
Send a JSON-RPC Notification to a UI session.java.util.concurrent.CompletableFuture<JsonrpcResponseSuccess>
send(java.lang.String token, JsonrpcRequest request)
Send a JSON-RPC Request to a UI session via WebSocket and expect a JSON-RPC Response.void
sendBroadcast(java.lang.String edgeId, JsonrpcNotification notification)
Send a JSON-RPC Notification broadcast to all UI sessions with a given Edge-ID.void
sendSubscribedChannels(java.lang.String edgeId, EdgeCache edgeCache)
Sends the subscribed Channels to the UI session.
-
-
-
Field Detail
-
server
protected WebsocketServer server
-
jsonRpcRequestHandler
protected volatile JsonRpcRequestHandler jsonRpcRequestHandler
-
metadata
protected volatile Metadata metadata
-
edgeWebsocket
protected volatile EdgeWebsocket edgeWebsocket
-
timedataManager
protected volatile TimedataManager timedataManager
-
-
Method Detail
-
logInfo
protected void logInfo(org.slf4j.Logger log, java.lang.String message)
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
protected void logWarn(org.slf4j.Logger log, java.lang.String message)
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
protected void logError(org.slf4j.Logger log, java.lang.String message)
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(java.lang.String token, 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:
token
- the UI tokennotification
- the JsonrpcNotification- Throws:
OpenemsError.OpenemsNamedException
- on error
-
send
public java.util.concurrent.CompletableFuture<JsonrpcResponseSuccess> send(java.lang.String token, 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:
token
- the UI tokenrequest
- the JsonrpcRequest- Returns:
- the JSON-RPC Success Response Future
- Throws:
OpenemsError.OpenemsNamedException
- on error
-
sendBroadcast
public void sendBroadcast(java.lang.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
public void sendSubscribedChannels(java.lang.String edgeId, EdgeCache edgeCache)
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
public 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
-
-