public class WebSocketServiceImpl extends Object implements WebSocketService
| Modifier and Type | Field and Description |
|---|---|
static String |
WEB_SOCKET_CONTAINER_FACTORY_PROPERTY |
| Constructor and Description |
|---|
WebSocketServiceImpl(javax.websocket.Session session)
Instantiates a new Web socket service.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMessageHandler(Consumer<String> consumer)
After receiving the message calls the consumer with appropriate message.
|
void |
close()
Closes the service.
|
boolean |
closed()
Checks if connection is closed.
|
void |
connect(URI uri)
Connects to a specified URI.
|
static WebSocketService |
create(URI uri)
Creates a web socket service implementation factory method.
|
static javax.websocket.WebSocketContainer |
getWebSocketContainer()
Returns a WebSocketContainer retrieved from class defined in system property
com.qeagle.devtools.services.config.webSocketContainerProvider.
|
void |
send(String message)
Sends the message using web socket.
|
public static final String WEB_SOCKET_CONTAINER_FACTORY_PROPERTY
public WebSocketServiceImpl(javax.websocket.Session session)
session - Session.public static WebSocketService create(URI uri) throws WebSocketServiceException
Creates a WebSocketService and connects to a specified uri.
uri - URI to connect to.WebSocketServiceException - If it fails to connect.public void connect(URI uri) throws WebSocketServiceException
WebSocketServiceconnect in interface WebSocketServiceuri - Server location.WebSocketServiceExceptionpublic void send(String message) throws WebSocketServiceException
WebSocketServicesend in interface WebSocketServicemessage - Message to send.WebSocketServiceExceptionpublic void addMessageHandler(Consumer<String> consumer) throws WebSocketServiceException
WebSocketServiceaddMessageHandler in interface WebSocketServiceconsumer - Consumer to consume the message.WebSocketServiceExceptionpublic void close()
WebSocketServiceclose in interface WebSocketServicepublic boolean closed()
WebSocketServiceclosed in interface WebSocketServicepublic static javax.websocket.WebSocketContainer getWebSocketContainer()
Copyright © 2020. All rights reserved.