Fixed bug allowing client to be in two different rooms at the same time
This commit is contained in:
@@ -50,7 +50,8 @@ public class Server implements PacketHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
rooms.put(roomName, new ArrayList<>());
|
rooms.put(roomName, new ArrayList<>());
|
||||||
rooms.get(roomName).add(connexion);
|
leaveRoom(connexion); // Leave the current room (auto handle if not in a room)
|
||||||
|
rooms.get(roomName).add(connexion); // Add the creator to the room
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ public class Server implements PacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean joinRoom(String roomName, ServerConnexion connexion) {
|
public boolean joinRoom(String roomName, ServerConnexion connexion) {
|
||||||
|
leaveRoom(connexion); // Leave the current room (auto handle if not in a room)
|
||||||
if (rooms.containsKey(roomName) && !rooms.get(roomName).contains(connexion)) {
|
if (rooms.containsKey(roomName) && !rooms.get(roomName).contains(connexion)) {
|
||||||
rooms.get(roomName).add(connexion);
|
rooms.get(roomName).add(connexion);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user