Changes to websocket
This commit is contained in:
parent
76aad82883
commit
71b03cb87d
@ -1,6 +1,7 @@
|
||||
package fi.flexplex.lib;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
|
||||
import com.neovisionaries.ws.client.WebSocket;
|
||||
import com.neovisionaries.ws.client.WebSocketAdapter;
|
||||
@ -19,11 +20,8 @@ public final class WebSocketClient {
|
||||
|
||||
protected void connect() {
|
||||
if (!webSocket.isOpen()) {
|
||||
try {
|
||||
this.webSocket.connect();
|
||||
} catch (final WebSocketException e) {
|
||||
flexLib.getLogger().warning("WebSocket connection to FlexPlex server failed.");
|
||||
}
|
||||
this.webSocket.connectAsynchronously();
|
||||
this.setWebSocketSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +29,15 @@ public final class WebSocketClient {
|
||||
this.webSocket.disconnect();
|
||||
}
|
||||
|
||||
private void setWebSocketSettings() {
|
||||
try {
|
||||
this.webSocket.getConnectedSocket().setSoTimeout(0);
|
||||
this.webSocket.getConnectedSocket().setKeepAlive(true);
|
||||
} catch (final SocketException | WebSocketException e) {
|
||||
this.flexLib.getLogger().warning("Failed to set WebSocket settings");
|
||||
}
|
||||
}
|
||||
|
||||
private WebSocket createWebSocket(final String url, final String token) throws IOException {
|
||||
return new WebSocketFactory()
|
||||
.createSocket(url)
|
||||
|
Loading…
Reference in New Issue
Block a user