Add websocket example
This commit is contained in:
@@ -2,9 +2,14 @@ package org.baeldung.model;
|
||||
|
||||
public class Message {
|
||||
|
||||
private String from;
|
||||
private String text;
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,13 @@ package org.baeldung.model;
|
||||
|
||||
public class OutputMessage {
|
||||
|
||||
private String from;
|
||||
private String text;
|
||||
private String time;
|
||||
|
||||
public OutputMessage(final String text, final String time) {
|
||||
public OutputMessage(final String from, final String text, final String time) {
|
||||
|
||||
this.from = from;
|
||||
this.text = text;
|
||||
this.time = time;
|
||||
}
|
||||
@@ -17,4 +20,8 @@ public class OutputMessage {
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ChatController {
|
||||
public OutputMessage send(final Message message) throws Exception {
|
||||
|
||||
final String time = new SimpleDateFormat("HH:mm").format(new Date());
|
||||
return new OutputMessage(message.getText(), time);
|
||||
return new OutputMessage(message.getFrom(), message.getText(), time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user