Continued NetworkControlTest
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@592 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
f5aa073827
commit
73c1072ba6
3 changed files with 75 additions and 25 deletions
|
@ -59,8 +59,8 @@ public class NetworkControl {
|
|||
this.connectionControl = connectionControl;
|
||||
this.saveControl = saveControl;
|
||||
|
||||
addConnectionSetupListeners(loginData, view);
|
||||
addConnectionControlListeners(view);
|
||||
addConnectionSetupListeners(loginData);
|
||||
addConnectionControlListeners();
|
||||
addViewEventListeners();
|
||||
}
|
||||
|
||||
|
@ -98,11 +98,8 @@ public class NetworkControl {
|
|||
|
||||
/**
|
||||
* Adds the listeners for connection control events
|
||||
*
|
||||
* @param view
|
||||
* view for events
|
||||
*/
|
||||
public void addConnectionControlListeners(final IView view) {
|
||||
private void addConnectionControlListeners() {
|
||||
addOfferUpdateListener();
|
||||
|
||||
connections.add(connectionControl.getGameWithdrawalEvent().add(
|
||||
|
@ -112,20 +109,6 @@ public class NetworkControl {
|
|||
games.remove(uuid);
|
||||
gameMap.remove(uuid);
|
||||
|
||||
updateGameList();
|
||||
}
|
||||
}));
|
||||
connections.add(connectionControl.getParticipantLeftEvent().add(
|
||||
new IListener1<String>() {
|
||||
@Override
|
||||
public void handle(String nickname) {
|
||||
for (Map.Entry<UUID, GameData> entry : gameMap.entrySet()) {
|
||||
if (entry.getValue().getHost().equals(nickname)) {
|
||||
games.remove(entry.getKey());
|
||||
gameMap.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
updateGameList();
|
||||
}
|
||||
}));
|
||||
|
@ -140,6 +123,28 @@ public class NetworkControl {
|
|||
}
|
||||
}
|
||||
}));
|
||||
addConnectionLostListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the listeners for lost connection events
|
||||
*/
|
||||
private void addConnectionLostListeners() {
|
||||
connections.add(connectionControl.getParticipantLeftEvent().add(
|
||||
new IListener1<String>() {
|
||||
@Override
|
||||
public void handle(String nickname) {
|
||||
for (Map.Entry<UUID, GameData> entry : gameMap.entrySet()) {
|
||||
if (entry.getValue().getHost().equals(nickname)) {
|
||||
games.remove(entry.getKey());
|
||||
gameMap.remove(entry.getKey());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
updateGameList();
|
||||
}
|
||||
}));
|
||||
connections.add(connectionControl.getConnectionLostEvent().add(
|
||||
new IListener() {
|
||||
@Override
|
||||
|
@ -181,8 +186,7 @@ public class NetworkControl {
|
|||
}));
|
||||
}
|
||||
|
||||
private void addConnectionSetupListeners(final LoginData loginData,
|
||||
final IView view) {
|
||||
private void addConnectionSetupListeners(final LoginData loginData) {
|
||||
connections.add(connectionControl.getConnectedEvent().add(new IListener() {
|
||||
@Override
|
||||
public void handle() {
|
||||
|
|
Reference in a new issue