network paket vollständig kommentiert
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@560 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
1823fb1610
commit
b7da5ad631
1 changed files with 18 additions and 2 deletions
|
@ -10,14 +10,28 @@ import jrummikub.util.IListener;
|
||||||
import jrummikub.util.IListener1;
|
import jrummikub.util.IListener1;
|
||||||
import jrummikub.util.IListener2;
|
import jrummikub.util.IListener2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn control for network games
|
||||||
|
*/
|
||||||
public class NetworkTurnControl extends AbstractTurnControl {
|
public class NetworkTurnControl extends AbstractTurnControl {
|
||||||
private IConnectionControl connectionControl;
|
private IConnectionControl connectionControl;
|
||||||
private Event1<IRoundState> stateUpdateEvent = new Event1<IRoundState>();
|
private Event1<IRoundState> stateUpdateEvent = new Event1<IRoundState>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new network turn control
|
||||||
|
*
|
||||||
|
* @param connectionControl
|
||||||
|
* the current connection control
|
||||||
|
*/
|
||||||
public NetworkTurnControl(IConnectionControl connectionControl) {
|
public NetworkTurnControl(IConnectionControl connectionControl) {
|
||||||
this.connectionControl = connectionControl;
|
this.connectionControl = connectionControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The state update event is emitted when the state is sent into the network
|
||||||
|
*
|
||||||
|
* @return the event
|
||||||
|
*/
|
||||||
public IEvent1<IRoundState> getStateUpdateEvent() {
|
public IEvent1<IRoundState> getStateUpdateEvent() {
|
||||||
return stateUpdateEvent;
|
return stateUpdateEvent;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +48,8 @@ public class NetworkTurnControl extends AbstractTurnControl {
|
||||||
connections.add(connectionControl.getTurnEndEvent().add(
|
connections.add(connectionControl.getTurnEndEvent().add(
|
||||||
new IListener2<IRoundState, InvalidTurnInfo>() {
|
new IListener2<IRoundState, InvalidTurnInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(IRoundState state, InvalidTurnInfo invalidTurnInfo) {
|
public void handle(IRoundState state,
|
||||||
|
InvalidTurnInfo invalidTurnInfo) {
|
||||||
endOfTurn(state, invalidTurnInfo);
|
endOfTurn(state, invalidTurnInfo);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
@ -48,7 +63,8 @@ public class NetworkTurnControl extends AbstractTurnControl {
|
||||||
timer.startTimer();
|
timer.startTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void endOfTurn(IRoundState roundState, InvalidTurnInfo invalidTurnInfo) {
|
private void endOfTurn(IRoundState roundState,
|
||||||
|
InvalidTurnInfo invalidTurnInfo) {
|
||||||
cleanUp();
|
cleanUp();
|
||||||
|
|
||||||
endOfTurnEvent.emit(roundState, invalidTurnInfo);
|
endOfTurnEvent.emit(roundState, invalidTurnInfo);
|
||||||
|
|
Reference in a new issue