Coverage Summary for Class: ClientDisconnected (it.polimi.ingsw.Server.Messages.ServerResponses)

Class Class, % Method, % Line, %
ClientDisconnected 0% (0/1) 0% (0/3) 0% (0/5)


1 package it.polimi.ingsw.Server.Messages.ServerResponses; 2  3 import java.io.Serial; 4 import java.util.List; 5  6 /** 7  * This Response is generated when a lobby's client disconnected and is sent to the lobby's clients. 8  * Therefore, it is {@link FixedStatusResponse} 9  */ 10 public class ClientDisconnected extends FixedStatusResponse { 11  12  @Serial 13  private static final long serialVersionUID = 304L; 14  private final String lastDisconnectedNickname; 15  16  private final List<String> players; 17  18  /** 19  * Create the response 20  * 21  * @param lastDisconnectedNickname the nickname of the player that just disconnected 22  * @param players the list of still connected players 23  */ 24  public ClientDisconnected(String lastDisconnectedNickname, List<String> players) { 25  this.lastDisconnectedNickname = lastDisconnectedNickname; 26  this.players = players; 27  } 28  29  /** 30  * Get the players still connected to the lobby 31  * 32  * @return an Unmodifiable {@link List} containing players still in the lobby 33  */ 34  public List<String> getPlayers() { 35  return List.copyOf(this.players); 36  } 37  38  /** 39  * Get the user that generated this response by disconnecting 40  * 41  * @return the nickname of the user that just disconnected from the lobby 42  */ 43  public String getLastDisconnectedNickname() { 44  return this.lastDisconnectedNickname; 45  } 46  47 }