Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void onMessage(Message message, byte[] pattern) {
createAndSendWebSocketMessage("newStudentAchievement", messageJSON, "achievement");
break;
case "annotationToStudent":
case "annotationToClassroom":
createAndSendWebSocketMessage("annotation", messageJSON, "annotation");
break;
case "notification":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,11 @@ private void sendAnnotationNotificationToStudent(Annotation annotation) {
try {
Notification notification = this.createNotificationForAnnotation(annotation);
Long toWorkgroupId = notification.getToWorkgroup().getId();
broadcastAnnotationToStudent(toWorkgroupId, annotation);
broadcastNotificationToStudent(toWorkgroupId, notification);
this.broadcastAnnotationToStudent(toWorkgroupId, annotation);
if (annotation.getType().equals("inappropriateFlag")) {
this.broadcastAnnotationToClassroom(annotation);
}
this.broadcastNotificationToStudent(toWorkgroupId, notification);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -217,7 +220,7 @@ private Notification createNotificationForAnnotation(Annotation annotation) {
return notification;
}

public void broadcastAnnotationToStudent(Long toWorkgroupId, Annotation annotation)
private void broadcastAnnotationToStudent(Long toWorkgroupId, Annotation annotation)
throws JSONException {
annotation.convertToClientAnnotation();
JSONObject message = new JSONObject();
Expand All @@ -227,7 +230,17 @@ public void broadcastAnnotationToStudent(Long toWorkgroupId, Annotation annotati
redisPublisher.publish(message.toString());
}

public void broadcastNotificationToStudent(Long toWorkgroupId, Notification notification)
private void broadcastAnnotationToClassroom(Annotation annotation) throws JSONException {
annotation.convertToClientAnnotation();
JSONObject message = new JSONObject();
message.put("type", "annotationToClassroom");
message.put("topic", String.format("/topic/classroom/%s/%s", annotation.getRun().getId(),
annotation.getPeriod().getId()));
message.put("annotation", annotation.toJSON());
redisPublisher.publish(message.toString());
}

private void broadcastNotificationToStudent(Long toWorkgroupId, Notification notification)
throws JSONException {
notification.convertToClientNotification();
JSONObject message = new JSONObject();
Expand All @@ -236,4 +249,5 @@ public void broadcastNotificationToStudent(Long toWorkgroupId, Notification noti
message.put("notification", notification.toJSON());
redisPublisher.publish(message.toString());
}

}