Skip to content
Snippets Groups Projects
Commit 391e8b23 authored by Christoph Thelen's avatar Christoph Thelen
Browse files

Code formatting

parent 83eba294
Branches
Tags
...@@ -73,54 +73,44 @@ public class ARSnovaSocketIOServer { ...@@ -73,54 +73,44 @@ public class ARSnovaSocketIOServer {
} }
server = new SocketIOServer(config); server = new SocketIOServer(config);
server.addEventListener("setFeedback", Feedback.class, server.addEventListener("setFeedback", Feedback.class, new DataListener<Feedback>() {
new DataListener<Feedback>() { @Override
@Override public void onData(SocketIOClient client, Feedback data, AckRequest ackSender) {
public void onData(SocketIOClient client, Feedback data, /**
AckRequest ackSender) { * do a check if user is in the session, for which he would give
/** * a feedback
* do a check if user is in the session, for which he */
* would give a feedback User u = userService.getUser2SocketId(client.getSessionId());
*/ if (u == null || userService.isUserInSession(u, data.getSessionkey()) == false) {
User u = userService.getUser2SocketId(client return;
.getSessionId()); }
if (u == null feedbackService.saveFeedback(data.getSessionkey(), data.getValue(), u);
|| userService.isUserInSession(u,
data.getSessionkey()) == false) { /**
return; * send feedback back to clients
} */
feedbackService.saveFeedback(data.getSessionkey(), reportUpdatedFeedbackForSession(data.getSessionkey());
data.getValue(), u); }
});
/**
* send feedback back to clients server.addEventListener("arsnova/question/create", Question.class, new DataListener<Question>() {
*/ @Override
reportUpdatedFeedbackForSession(data.getSessionkey()); public void onData(SocketIOClient client, Question question, AckRequest ackSender) {
} questionService.saveQuestion(question);
}); }
});
server.addEventListener("arsnova/question/create", Question.class,
new DataListener<Question>() {
@Override
public void onData(SocketIOClient client,
Question question, AckRequest ackSender) {
questionService.saveQuestion(question);
}
});
server.addConnectListener(new ConnectListener() { server.addConnectListener(new ConnectListener() {
@Override @Override
public void onConnect(SocketIOClient client) { public void onConnect(SocketIOClient client) {
logger.info("addConnectListener.onConnect: Client: {}", logger.info("addConnectListener.onConnect: Client: {}", new Object[] { client });
new Object[] { client });
} }
}); });
server.addDisconnectListener(new DisconnectListener() { server.addDisconnectListener(new DisconnectListener() {
@Override @Override
public void onDisconnect(SocketIOClient client) { public void onDisconnect(SocketIOClient client) {
logger.info("addDisconnectListener.onDisconnect: Client: {}", logger.info("addDisconnectListener.onDisconnect: Client: {}", new Object[] { client });
new Object[] { client });
userService.removeUser2SocketId(client.getSessionId()); userService.removeUser2SocketId(client.getSessionId());
} }
}); });
...@@ -208,9 +198,9 @@ public class ARSnovaSocketIOServer { ...@@ -208,9 +198,9 @@ public class ARSnovaSocketIOServer {
public void reportUpdatedFeedbackForSession(String session) { public void reportUpdatedFeedbackForSession(String session) {
/** /**
* collect a list of users which are in the current * collect a list of users which are in the current session iterate over
* session iterate over all connected clients and if * all connected clients and if send feedback, if user is in current
* send feedback, if user is in current session * session
*/ */
List<String> users = userService.getUsersInSession(session); List<String> users = userService.getUsersInSession(session);
de.thm.arsnova.entities.Feedback fb = feedbackService.getFeedback(session); de.thm.arsnova.entities.Feedback fb = feedbackService.getFeedback(session);
...@@ -218,10 +208,10 @@ public class ARSnovaSocketIOServer { ...@@ -218,10 +208,10 @@ public class ARSnovaSocketIOServer {
for (SocketIOClient c : server.getAllClients()) { for (SocketIOClient c : server.getAllClients()) {
User u = userService.getUser2SocketId(c.getSessionId()); User u = userService.getUser2SocketId(c.getSessionId());
if (u != null && users.contains(u.getUsername())) { if (u != null && users.contains(u.getUsername())) {
logger.info("sending out to client {}, username is: {}, current session is: {}", logger.info("sending out to client {}, username is: {}, current session is: {}",
new Object[] {c.getSessionId(), u.getUsername(), session}); new Object[] { c.getSessionId(), u.getUsername(), session });
c.sendEvent("updateFeedback", fb.getValues()); c.sendEvent("updateFeedback", fb.getValues());
} }
} }
} }
} }
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment