Switch to main menu when disconnect
This commit is contained in:
parent
7e51abf1df
commit
9a34bfda4a
@ -70,6 +70,10 @@ public class GameCanvas extends DoubleBufferedCanvas implements Runnable, Networ
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(int status, Object data) {
|
||||
if (status == ON_DISCONNECT) {
|
||||
onExit();
|
||||
return;
|
||||
}
|
||||
if (serverInstance) serverNetworkStatus(status, data);
|
||||
else clientNetworkStatus(status, data);
|
||||
}
|
||||
|
@ -8,9 +8,10 @@ public interface NetworkListener {
|
||||
|
||||
public static final int
|
||||
ON_CONNECT = 1,
|
||||
ON_SEED_RECEIVED = 2,
|
||||
ON_MOVE_RECEIVED = 3,
|
||||
ON_NEW_ROUND = 4;
|
||||
ON_DISCONNECT = 2,
|
||||
ON_SEED_RECEIVED = 3,
|
||||
ON_MOVE_RECEIVED = 4,
|
||||
ON_NEW_ROUND = 5;
|
||||
|
||||
public void onStatusChanged(int status, Object data);
|
||||
}
|
||||
|
@ -40,8 +40,9 @@ public class SocketHelper extends Thread {
|
||||
listener.onStatusChanged(status, receiveMove());
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (IOException ex) { }
|
||||
} catch (IOException ex) {
|
||||
listener.onStatusChanged(NetworkListener.ON_DISCONNECT, null);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException ex) { }
|
||||
|
Loading…
Reference in New Issue
Block a user