Skip to content

Commit

Permalink
Cleanup peer state in all cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Brutus5000 committed Jun 12, 2024
1 parent 27d215a commit ba5d9b2
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,24 +279,9 @@ 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) {
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 +310,21 @@ 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 (iceState == DISCONNECTED) {
log.warn(getLogPrefix() + "Lost connection, albeit already in ice state disconnected");
return;//TODO: will this kill the life cycle?
}

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

0 comments on commit ba5d9b2

Please sign in to comment.