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:
Jannis Mattheis
2018-11-04 09:12:44 +01:00
parent ca0194e3bb
commit ee4d87113f
2 changed files with 14 additions and 3 deletions

View File

@@ -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();