Package io.openems.common.websocket
Class AbstractWebsocket<T extends WsData>
java.lang.Object
io.openems.common.websocket.AbstractWebsocket<T>
- Direct Known Subclasses:
AbstractWebsocketClient
,AbstractWebsocketServer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
Creates an empty WsData object that is attached to the WebSocket as early as possible.protected abstract void
Execute aRunnable
.getName()
Gets the internal name of this websocket client/server.protected abstract OnClose
Callback for websocket OnClose event.protected abstract OnError
Callback for websocket error.protected abstract OnInternalError
Callback for internal error.protected abstract OnNotification
Callback for JSON-RPC notification.protected abstract OnOpen
Callback for websocket OnOpen event.protected abstract OnRequest
Callback for JSON-RPC request.protected void
handleInternalErrorAsync
(Throwable t, String wsDataString) Handles an internal Error asynchronously.protected void
handleInternalErrorSync
(Throwable t, String wsDataString) Handles an internal Error synchronously.protected abstract void
Log a error message.protected abstract void
Log a info message.protected abstract void
Log a warn message.protected void
start()
protected void
stop()
-
Constructor Details
-
AbstractWebsocket
Construct thisAbstractWebsocket
.- Parameters:
name
- a name that is used to identify log messages
-
-
Method Details
-
createWsData
Creates an empty WsData object that is attached to the WebSocket as early as possible.- Returns:
- the typed
WsData
-
getOnInternalError
Callback for internal error.- Returns:
- the
OnInternalError
callback
-
getOnOpen
Callback for websocket OnOpen event.- Returns:
- the
OnOpen
callback
-
getOnRequest
Callback for JSON-RPC request.- Returns:
- the
OnRequest
callback
-
getOnNotification
Callback for JSON-RPC notification.- Returns:
- the
OnNotification
callback
-
getOnError
Callback for websocket error.- Returns:
- the
OnError
callback
-
getOnClose
Callback for websocket OnClose event.- Returns:
- the
OnClose
callback
-
getName
Gets the internal name of this websocket client/server.- Returns:
- the internal name
-
start
protected void start() -
stop
protected void stop() -
execute
Execute aRunnable
. -
handleInternalErrorAsync
Handles an internal Error asynchronously.- Parameters:
t
- theThrowable
to be handledwsDataString
- the toString() content of the WsData attachment of the WebSocket
-
handleInternalErrorSync
Handles an internal Error synchronously.- Parameters:
t
- theThrowable
to be handledwsDataString
- the toString() content of the WsData attachment of the WebSocket
-
logInfo
Log a info message.- Parameters:
log
- a Logger instancemessage
- the message
-
logWarn
Log a warn message.- Parameters:
log
- a Logger instancemessage
- the message
-
logError
Log a error message.- Parameters:
log
- a Logger instancemessage
- the message
-