Added vote and hasVoted fields to ClientHandler for later transmission to corresponding Passenger
This commit is contained in:
parent
d373242486
commit
370e1e97fe
@ -21,6 +21,7 @@ public class ClientHandler implements Runnable {
|
||||
private Socket socket;
|
||||
private InetAddress ip;
|
||||
|
||||
|
||||
/**
|
||||
* notes if the client has formally logged in yet. If connecting through the normal Client class,
|
||||
* the client is logged in automatically, if connecting though some external application, the
|
||||
@ -34,6 +35,8 @@ public class ClientHandler implements Runnable {
|
||||
public static HashSet<ClientHandler> disconnectedClients = new HashSet<>(); //todo: implement re-connection
|
||||
public static HashSet<ClientHandler> lobby = new HashSet<>();
|
||||
public static HashSet<ClientHandler> ghostClients = new HashSet<>();
|
||||
private int vote; //saves vote of clientHandler for later transmission to passenger, by default MAX_VALUE
|
||||
private boolean hasVoted; //saves hasVoted status of clientHandler for later transmission to passenger, by default false
|
||||
|
||||
/**
|
||||
* Implements the login logic in client-server architecture.
|
||||
@ -48,6 +51,8 @@ public class ClientHandler implements Runnable {
|
||||
this.in = new BufferedReader(new InputStreamReader((socket.getInputStream())));
|
||||
this.loggedIn = false;
|
||||
this.clientUserName = nameDuplicateChecker.checkName("U.N. Owen");
|
||||
this.vote = Integer.MAX_VALUE;
|
||||
this.hasVoted = false;
|
||||
connectedClients.add(this);
|
||||
serverPinger = new ServerPinger(socket, this);
|
||||
Thread sP = new Thread(serverPinger);
|
||||
@ -86,15 +91,30 @@ public class ClientHandler implements Runnable {
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
public int getVote() {
|
||||
return vote;
|
||||
}
|
||||
|
||||
public boolean getHasVoted() {
|
||||
return hasVoted;
|
||||
}
|
||||
|
||||
public String getClientUserName() {
|
||||
return clientUserName;
|
||||
}
|
||||
//Setters:
|
||||
|
||||
public void setLoggedIn(boolean loggedIn) {
|
||||
this.loggedIn = loggedIn;
|
||||
}
|
||||
|
||||
//Setters:
|
||||
public String getClientUserName() {
|
||||
return clientUserName;
|
||||
public void setVote(int vote) {
|
||||
this.vote = vote;
|
||||
}
|
||||
|
||||
public void setHasVoted(boolean hasVoted) {
|
||||
this.hasVoted = hasVoted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@ -67,7 +67,7 @@ public class JServerProtocolParser {
|
||||
break;
|
||||
case Protocol.listLobbies:
|
||||
//TODO: add action
|
||||
LOGGER.debug(Protocol.listLobbies + " command recieved from: " + h.getClientUserName());
|
||||
LOGGER.debug(Protocol.listLobbies + " command received from: " + h.getClientUserName());
|
||||
break;
|
||||
case Protocol.votedFor:
|
||||
int vote = Integer.parseInt(msg.substring(6));
|
||||
|
||||
Reference in New Issue
Block a user