Class WsAdapter
java.lang.Object
de.iip_ecosphere.platform.services.environment.services.WsAdapter
- Direct Known Subclasses:
PythonWsProcessService.PyWebSocket,WsSenderClient,WsWatcher
Adapts the web sockets to the interface used before.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the socket.voidCloses the socket while blocking.voidconnect()Connects the socket.booleanConnects and blocks until connected or failed.getURI()Returns the socket URI.booleanisClosed()Returns whether the socket is closed.booleanisOpen()Returns whether the socket is open.protected abstract voidCalled when a message arrived.voidSends the given text through the websocket.
-
Field Details
-
socket
private de.iip_ecosphere.platform.support.websocket.WebsocketFactory.WebSocket socket -
logger
private de.iip_ecosphere.platform.support.logging.Logger logger -
lastError
-
-
Constructor Details
-
WsAdapter
Creates a web socket for the given server URI.- Parameters:
serverUri- the server URI
-
-
Method Details
-
onMessage
Called when a message arrived.- Parameters:
text- the message text
-
send
Sends the given text through the websocket.- Parameters:
text- the text to send- Throws:
IOException- if sending fails
-
close
public void close()Closes the socket. -
connectBlocking
public boolean connectBlocking()Connects and blocks until connected or failed.- Returns:
- whether connecting was successful
-
getURI
Returns the socket URI.- Returns:
- the URI
-
connect
public void connect()Connects the socket. -
isOpen
public boolean isOpen()Returns whether the socket is open.- Returns:
truefor open,falseelse
-
isClosed
public boolean isClosed()Returns whether the socket is closed.- Returns:
truefor closed,falseelse
-
closeBlocking
Closes the socket while blocking.- Throws:
IOException- if closing fails
-