Interface WebsocketFactory.WebSocket
- Enclosing class:
WebsocketFactory
public static interface WebsocketFactory.WebSocket
A web socket.
- Author:
- Holger Eichelberger, SSE
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the socket.voidCloses the socket, waits for closing.voidconnect()Connects without blocking.booleanConnects and blocks until connected or failed.getURI()Returns the URI this socket is connected to.booleanisClosed()Returns whether the socket is closed.booleanisOpen()Returns whether the socket is open.voidSends the given text through the websocket.voidsetReceptionHander(Consumer<String> receptionHandler) Sets the reception handler for incoming messages.voidSets the status listener.
-
Method Details
-
setReceptionHander
Sets the reception handler for incoming messages.- Parameters:
receptionHandler- the response handler
-
setStatusListener
Sets the status listener.- Parameters:
listener- the listener
-
connect
Connects without blocking.- Throws:
IOException- if connection fails
-
connectBlocking
Connects and blocks until connected or failed.- Returns:
- whether connecting was successful
- Throws:
IOException- if connection fails
-
send
Sends the given text through the websocket.- Parameters:
text- the text to send- Throws:
IOException- if sending fails
-
close
Closes the socket.- Throws:
IOException- if closing fails
-
closeBocking
Closes the socket, waits for closing.- Throws:
IOException- if closing fails
-
getURI
URI getURI()Returns the URI this socket is connected to.- Returns:
- the URI
-
isOpen
boolean isOpen()Returns whether the socket is open.- Returns:
truefor open,falseelse
-
isClosed
boolean isClosed()Returns whether the socket is closed.- Returns:
truefor closed,falseelse
-