parent
6498b8ab33
commit
a189fedd76
|
@ -66,7 +66,4 @@ public class Message implements Serializable {
|
|||
return text;
|
||||
}
|
||||
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -169,7 +169,6 @@ public class ServerConnectionHandler extends ConnectionHandler implements Runnab
|
|||
*/
|
||||
private void caseConnect(Message data) throws ChatProtocolException {
|
||||
if (this.state != NEW) throw new ChatProtocolException("Illegal state for connect request: " + state);
|
||||
if (data.getSender().isBlank()) data.setSender(this.userName);
|
||||
//if username not valid
|
||||
if (connectionRegistry.containsKey(data.getSender())) {
|
||||
state = ERROR;
|
||||
|
@ -179,7 +178,9 @@ public class ServerConnectionHandler extends ConnectionHandler implements Runnab
|
|||
throw new ChatProtocolException("User name already taken: " + data.getSender());
|
||||
}
|
||||
//if username valid
|
||||
if (!data.getSender().isBlank()) {
|
||||
this.userName = data.getSender();
|
||||
}
|
||||
connectionRegistry.put(userName, this);
|
||||
sendData(USER_NONE, userName, getDataTypeConfirm(), "Registration successful for " + userName);
|
||||
this.state = CONNECTED;
|
||||
|
|
Loading…
Reference in New Issue