Add websocket example

This commit is contained in:
Ivan Paolillo
2016-05-05 10:37:56 +02:00
parent 889b266107
commit ed72ff42e8
4 changed files with 23 additions and 4 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}