Skip to content

Commit 8c76512

Browse files
committed
Merge branch 'websocketVsRest'
2 parents 35405ed + 44c2d70 commit 8c76512

File tree

8 files changed

+62
-11
lines changed

8 files changed

+62
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ you probably know the syntax (because you understand whats going on).
173173
But if I work with some Students or ppl. new to Spring, they really create every combination of parentheses,
174174
dollars, braces and so on.
175175

176-
With Spring Boot those @ConfigurationProperties` can be used.
176+
With Spring Boot those `@ConfigurationProperties` can be used.
177177

178178
![Image of our Solution](diary/highlightConfig.png)
179179

src/main/java/de/votesapp/client/WebClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ public class WebClient implements WhatsAppClient {
2626

2727
private volatile List<GroupMessage> groupMessages = new ArrayList<>();
2828

29+
private volatile GroupMessage last;
30+
2931
@Override
3032
public void sendGroupMessage(final GroupMessage messageToSend) {
33+
last = messageToSend;
3134
brokerMessagingTemplate.convertAndSend("/receive", messageToSend);
3235
}
3336

@@ -40,6 +43,11 @@ public GroupMessage[] fetchGroupMessages() {
4043
}
4144
}
4245

46+
@RequestMapping("/last")
47+
public GroupMessage re() {
48+
return last;
49+
}
50+
4351
@RequestMapping("/send")
4452
public void sendPerRest(@RequestBody final SendModel sm) {
4553
synchronized (groupMessages) {

src/main/java/de/votesapp/commands/plugins/SetAttitudeCommandPlugin.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
@Service
2323
public class SetAttitudeCommandPlugin implements CommandPlugin, Describable {
2424

25-
public static final String[] DEFAULT_POSITIVES = { "ok", "in", "I'm in", "yes", "ja", "Bin dabei", Attitude.POSITIVE.getIcon() };
26-
public static final String[] DEFAULT_NEGATIVES = { "out", "no", "nope", "nein", "Bin nicht dabei", "Komme nicht", Attitude.NEGATIVE.getIcon() };
25+
public static final String[] DEFAULT_POSITIVES = { "ok", "in", "i'm in", "yes", "ja", "bin dabei", Attitude.POSITIVE.getIcon() };
26+
public static final String[] DEFAULT_NEGATIVES = { "out", "no", "nope", "nein", "bin nicht dabei", "komme nicht", "bin raus", "kann nicht",
27+
Attitude.NEGATIVE.getIcon() };
2728
public static final String[] DEFAULT_UNKOWN = { "maybe", "vielleicht", Attitude.UNKOWN.getIcon() };
2829

2930
private final ImmutableMultimap<String, Attitude> words;

src/main/resources/static/bootstrap.min.css

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/static/bootstrap.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/static/index.html

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<html>
33
<head>
44
<title>VotesApp WebClient Frontend</title>
5-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
6-
<script src="//cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js"></script>
5+
<script src="jquery.min.js"></script>
6+
<script src="sockjs.min.js"></script>
77
<script src="stomp.min.js"></script>
88
<script type="text/javascript">
99
$(function() {
@@ -14,8 +14,8 @@
1414
console.log('Connected: ' + frame);
1515
stompClient.subscribe('/receive', function(msg){
1616
var body = JSON.parse(msg.body);
17-
var content = { text: body.text, groupId: body.groupId };
18-
$("#msgs").append('<div class="alert alert-info" role="alert"><strong>' + body.groupId + '</strong> ' + body.text +'</div>');
17+
var content = { text: body.text.replace(/\n/g, '<br>'), groupId: body.groupId };
18+
$("#msgs").append('<div class="alert alert-info" role="alert"><strong>' + content.groupId + '</strong> ' + content.text +'</div>');
1919
});
2020
});
2121
}
@@ -30,15 +30,14 @@
3030
type: "POST",
3131
url: "/send",
3232
data: JSON.stringify({phone: phone, group: group, text: text}),
33-
contentType: "application/json; charset=utf-8",
34-
dataType: "json"
33+
contentType: "application/json; charset=utf-8"
3534
});
3635
$("#msgs").append('<div class="alert alert-success" role="alert"><strong>' + group + '</strong> ' + text +'</div>');
3736
});
3837
});
3938
</script>
4039

41-
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
40+
<link rel="stylesheet" href="bootstrap.min.css">
4241
</head>
4342
<body>
4443
<noscript><h2 style="color: #ff0000">Please enable Javascript and reload this page!</h2></noscript>
@@ -63,6 +62,6 @@ <h1>Debug VotestApp Interface</h1>
6362
<div id="msgs"></div>
6463
</div>
6564

66-
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
65+
<script src="bootstrap.min.js"></script>
6766
</body>
6867
</html>

src/main/resources/static/jquery.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/static/sockjs.min.js

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)