Client feritg, exit funktioniert und Verbindungsabbruch etc. geklärt. Start Button hinzugefügt, welcher auch den Usernamen unveränderlich macht. Time zu den Messages als Attribut hinzugefügt.
This commit is contained in:
parent
e752709cdb
commit
70dded9ca2
3 changed files with 179 additions and 65 deletions
|
@ -1,33 +1,43 @@
|
|||
package utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.Date;
|
||||
|
||||
public class Message implements Serializable {
|
||||
|
||||
String username;
|
||||
String message;
|
||||
//String date = new SimpleDateFormat("dd-MM-yyyy").format(new Date());
|
||||
//LocalDateTime current = LocalDateTime.now();
|
||||
//DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
|
||||
//String date = current.format(formatter);
|
||||
|
||||
String time = "00:00";
|
||||
/*
|
||||
LocalDateTime current = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
|
||||
String date = current.format(formatter);
|
||||
*/
|
||||
public Message(String username, String message) {
|
||||
this.username = username;
|
||||
this.message = message;
|
||||
this.time = new SimpleDateFormat("HH.mm.ss").format(new Date());
|
||||
//this.date = date;
|
||||
}
|
||||
|
||||
/*
|
||||
public String getMessage(){
|
||||
return this.message;
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "nickname=" + username
|
||||
+ ", message=" + message;
|
||||
+ ", message=" + message
|
||||
+ ", time =" + time;
|
||||
//+ ", time=" + date;
|
||||
}
|
||||
|
||||
public boolean exit() {
|
||||
|
||||
public boolean exit() {
|
||||
if(message.equalsIgnoreCase("exit")){
|
||||
return false;
|
||||
}
|
||||
|
@ -41,5 +51,11 @@ public class Message implements Serializable {
|
|||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getTime(){
|
||||
return time;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue