Skip to content

Commit 1bceab8

Browse files
committed
remove unused class LobbyUsers
1 parent f423ae9 commit 1bceab8

File tree

5 files changed

+10
-53
lines changed

5 files changed

+10
-53
lines changed

src/main/java/com/bernd/ActiveGames.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
public class ActiveGames {
1616

1717
private final StatusMap statusMap;
18-
private final Map<String, ActiveGame> map = new LinkedHashMap<>();
18+
private final Map<String, ActiveGame> cache = new LinkedHashMap<>();
1919

2020
ActiveGames(StatusMap statusMap) {
2121
this.statusMap = statusMap;
2222
}
2323

2424
ActiveGame put(ActiveGame game) {
25-
map.put(game.id(), game);
25+
cache.put(game.id(), game);
2626
return game;
2727
}
2828

2929
ActiveGameList games() {
3030
Set<String> active = statusMap.activeGames();
3131
List<ActiveGame> result = new ArrayList<>(active.size());
3232
for (String gameId : active) {
33-
ActiveGame game = map.get(gameId);
33+
ActiveGame game = cache.get(gameId);
3434
if (game != null) {
3535
result.add(game);
3636
}

src/main/java/com/bernd/LobbyController.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,18 @@
2323
public class LobbyController {
2424

2525
private final MessageSendingOperations<String> operations;
26-
private final LobbyUsers lobbyUsers;
2726
private final Games games;
2827
private final OpenGames openGames;
2928
private final ActiveGames activeGames;
3029
private final Chats chats;
3130

3231
LobbyController(
3332
MessageSendingOperations<String> operations,
34-
LobbyUsers lobbyUsers,
3533
OpenGames openGames,
3634
Games games,
3735
ActiveGames activeGames,
3836
Chats chats) {
3937
this.operations = operations;
40-
this.lobbyUsers = lobbyUsers;
4138
this.games = games;
4239
this.openGames = openGames;
4340
this.activeGames = activeGames;
@@ -47,8 +44,6 @@ public class LobbyController {
4744
@GetMapping(value = "/api/lobby/hello")
4845
public ResponseEntity<?> sayHello() {
4946
String principal = Auth.getPrincipal();
50-
lobbyUsers.add(principal);
51-
operations.convertAndSend("/topic/lobby/users", lobbyUsers.users());
5247
operations.convertAndSend("/topic/lobby/open_games", openGames.games());
5348
operations.convertAndSend("/topic/lobby/active_games", activeGames.games());
5449
return ResponseEntity.ok().build();
@@ -70,8 +65,6 @@ public OpenGameList getOpenGames() {
7065
@PostMapping(value = "/api/start_edit", consumes = "application/json")
7166
public ViewGame startEdit(@RequestBody MatchRequest request) {
7267
String principal = Auth.getPrincipal();
73-
lobbyUsers.remove(principal);
74-
operations.convertAndSend("/topic/lobby/users", lobbyUsers.users());
7568
Game game = games.put(new Game(
7669
RandomString.get(),
7770
principal,

src/main/java/com/bernd/LobbyUsers.java

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
package com.bernd;
22

3-
import java.security.Principal;
43
import org.springframework.context.ApplicationListener;
54
import org.springframework.messaging.core.MessageSendingOperations;
65
import org.springframework.stereotype.Component;
76
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
87

8+
import java.security.Principal;
9+
910
@Component
1011
public class SessionDisconnectEventListener implements ApplicationListener<SessionDisconnectEvent> {
1112

1213
private final MessageSendingOperations<String> operations;
13-
private final LobbyUsers lobbyUsers;
1414
private final Users users;
1515
private final OpenGames openGames;
1616

1717
SessionDisconnectEventListener(
1818
MessageSendingOperations<String> operations,
19-
LobbyUsers lobbyUsers,
2019
Users users,
2120
OpenGames openGames) {
2221
this.operations = operations;
23-
this.lobbyUsers = lobbyUsers;
2422
this.users = users;
2523
this.openGames = openGames;
2624
}
@@ -32,10 +30,8 @@ public void onApplicationEvent(SessionDisconnectEvent event) {
3230
return;
3331
}
3432
String name = user.getName();
35-
lobbyUsers.remove(name);
3633
users.logout(name);
3734
openGames.remove(name);
38-
operations.convertAndSend("/topic/lobby/users", lobbyUsers.users());
3935
operations.convertAndSend("/topic/lobby/open_games", openGames.games());
4036
}
4137
}

src/main/java/com/bernd/model/Game.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.bernd.model;
22

3+
import com.bernd.game.Board;
34
import com.bernd.game.Count;
45
import com.bernd.game.Direction;
56
import com.bernd.game.MoveList;
67
import com.bernd.game.Toggle;
7-
import com.bernd.game.Board;
88
import com.bernd.util.BoardUpdateImpl;
99
import com.bernd.util.Util;
1010
import org.apache.logging.log4j.LogManager;
@@ -44,8 +44,7 @@ private Game updateInternal(Move move) {
4444
moves.add(move);
4545
}
4646
if (move.agreeCounting()) {
47-
return toBuilder()
48-
.build();
47+
return toBuilder().build();
4948
}
5049
if (counting) {
5150
int[][] updated = move.resetCounting() ?
@@ -195,9 +194,9 @@ public boolean isForbidden(Move move) {
195194
public String getScore() {
196195
int w = 0;
197196
int b = 0;
198-
for (int y = 0; y < board().length; y++){
199-
for (int x = 0; x < board[y].length; x++){
200-
int color = board[y][x];
197+
for (int y = 0; y < board().length; y++) {
198+
for (int x = 0; x < board[y].length; x++) {
199+
int color = board[y][x];
201200
if ((color & (Board.W | Board.TERRITORY_W)) != 0) {
202201
w++;
203202
}

0 commit comments

Comments
 (0)