Fix websocket connection on refresh
On refresh the service was restarted but the connection wasn't closed, therefore each incoming message was handled n times.
This commit is contained in:
@@ -58,6 +58,11 @@ public class WebSocketService extends Service {
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.init(this);
|
||||
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
}
|
||||
|
||||
Log.i("Starting " + getClass().getSimpleName());
|
||||
super.onStartCommand(intent, flags, startId);
|
||||
new Thread(this::startPushService).run();
|
||||
|
||||
Reference in New Issue
Block a user