Skip to content

Commit

Permalink
Cleanup peer state in known final cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Jun 13, 2024
1 parent 136dedd commit 81cbd98
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,24 +279,14 @@ private void startIce() {
* Will then reinitiate ICE
*/
public synchronized void onConnectionLost() {
if(peer.isClosing()) {
log.warn(getLogPrefix() + "Peer not connected anymore, aborting onConnectionLost of ICE");
return;
}

if(peer.getGameSession().isGameEnded()) {
log.warn("GAME ENDED, ABORTING onConnectionLost of ICE for peer " + getLogPrefix());
return;
}

if (iceState == DISCONNECTED) {
log.warn(getLogPrefix() + "Lost connection, albeit already in ice state disconnected");
return;//TODO: will this kill the life cycle?
}

IceState previousState = getIceState();

if (listenerThread != null) {
// listenerThread.stop();//TODO what if cancelled during sending TO FA???
listenerThread.interrupt();
listenerThread = null;
}
Expand Down Expand Up @@ -325,6 +315,16 @@ public synchronized void onConnectionLost() {

debug().peerStateChanged(this.peer);

if(peer.isClosing()) {
log.warn(getLogPrefix() + "Peer not connected anymore, aborting onConnectionLost of ICE");
return;
}

if(peer.getGameSession().isGameEnded()) {
log.warn(getLogPrefix() + "GAME ENDED, ABORTING onConnectionLost of ICE for peer ");
return;
}

if (previousState == CONNECTED) {
TrayIcon.showMessage("Reconnecting to " + this.peer.getRemoteLogin() + " (connection lost)");
}
Expand Down

0 comments on commit 81cbd98

Please sign in to comment.