Skip to content

Commit b0fb8ca

Browse files
committed
refactor(server): remove unnecessary update listening mechanisms
1 parent 3fbb27d commit b0fb8ca

File tree

6 files changed

+25
-83
lines changed

6 files changed

+25
-83
lines changed

sdk/src/server-api/sc/networking/clients/ControllingClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
5-
65
import sc.framework.plugins.Player;
76
import sc.protocol.requests.CancelRequest;
87
import sc.protocol.requests.PauseGameRequest;
@@ -99,7 +98,6 @@ public void cancel() {
9998
public void onGamePaused(String roomId, Player nextPlayer) {
10099
logger.info("A PAUSE HIT was detected.");
101100
this.pauseHitReceived = true;
102-
this.notifyOnUpdate();
103101
}
104102

105103
@Override

sdk/src/server-api/sc/networking/clients/IControllableGame.java

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package sc.networking.clients
2+
3+
import sc.shared.GameResult
4+
5+
interface IControllableGame {
6+
fun next()
7+
fun hasNext(): Boolean
8+
9+
fun previous()
10+
fun pause()
11+
fun unpause()
12+
fun hasPrevious(): Boolean
13+
val isPaused: Boolean
14+
fun cancel()
15+
val currentState: Any?
16+
val currentError: Any?
17+
val isAtEnd: Boolean
18+
val isAtStart: Boolean
19+
fun goToFirst()
20+
fun goToLast()
21+
fun canTogglePause(): Boolean
22+
val result: GameResult?
23+
val isGameOver: Boolean
24+
val isReplay: Boolean
25+
}

sdk/src/server-api/sc/networking/clients/IPollsHistory.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
public interface IPollsHistory {
44
void start();
5-
65
void addListener(IHistoryListener listener);
7-
86
void removeListener(IHistoryListener listener);
97
}

sdk/src/server-api/sc/networking/clients/IPollsUpdates.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

sdk/src/server-api/sc/networking/clients/ObservingClient.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public ObservingClient(String roomId, boolean isPaused) {
2828
private boolean gameOver = false;
2929

3030
private final List<ProtocolMessage> history = new ArrayList<>();
31-
private final List<IUpdateListener> listeners = new ArrayList<>();
3231

3332
private GameResult result = null;
3433

@@ -54,37 +53,13 @@ public void onNewState(String roomId, IGameState state) {
5453
logger.debug("{} got new state {}", this, state);
5554
if (isAffected(roomId)) {
5655
addObservation(state);
57-
notifyOnUpdate();
5856
}
5957
}
6058

6159
protected boolean isAffected(String roomId) {
6260
return this.replay || this.roomId.equals(roomId);
6361
}
6462

65-
protected void notifyOnUpdate() {
66-
for (IUpdateListener listener : this.listeners) {
67-
listener.onUpdate(this);
68-
}
69-
}
70-
71-
protected void notifyOnError(String errorMessage) {
72-
for (IUpdateListener listener : this.listeners) {
73-
listener.onError(errorMessage);
74-
}
75-
}
76-
77-
@Override
78-
public void removeListener(IUpdateListener u) {
79-
this.listeners.remove(u);
80-
}
81-
82-
@Override
83-
public void addListener(IUpdateListener u) {
84-
this.listeners.add(u);
85-
u.onUpdate(this);
86-
}
87-
8863
@Override
8964
public void next() {
9065
this.changePosition(+1);
@@ -93,7 +68,6 @@ public void next() {
9368
@Override
9469
public void pause() {
9570
paused = true;
96-
notifyOnUpdate();
9771
}
9872

9973
@Override
@@ -129,7 +103,6 @@ protected void setPosition(int i) {
129103
logger.debug("Setting Position to {} (requested {})", newPosition, i);
130104
if (newPosition != this.position) {
131105
this.position = newPosition;
132-
notifyOnUpdate();
133106
}
134107
}
135108

@@ -204,8 +177,6 @@ public void onGameOver(String roomId, GameResult result) {
204177

205178
this.gameOver = true;
206179
this.result = result;
207-
208-
notifyOnUpdate();
209180
}
210181

211182
@Override
@@ -244,7 +215,6 @@ public void onGameError(String roomId, ProtocolErrorMessage error) {
244215
logger.debug("{} (room: {})", error.getLogMessage(), roomId);
245216
if (isAffected(roomId)) {
246217
addObservation(error);
247-
notifyOnError(error.getMessage());
248218
}
249219
}
250220

0 commit comments

Comments
 (0)