From 1445b6e9769200ca291a79d1e5b841a9b3e9feb9 Mon Sep 17 00:00:00 2001
From: Daniel Gerhardt <daniel.gerhardt@mni.thm.de>
Date: Sun, 25 May 2014 16:02:52 +0200
Subject: [PATCH] Fix NotFoundExeptions for setSession event in Socket.IO
 implementation

---
 .../java/de/thm/arsnova/services/SessionService.java  |  7 ++++++-
 .../de/thm/arsnova/socket/ARSnovaSocketIOServer.java  | 11 ++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/main/java/de/thm/arsnova/services/SessionService.java b/src/main/java/de/thm/arsnova/services/SessionService.java
index 07747a1c..91e39e99 100644
--- a/src/main/java/de/thm/arsnova/services/SessionService.java
+++ b/src/main/java/de/thm/arsnova/services/SessionService.java
@@ -65,7 +65,12 @@ public class SessionService implements ISessionService {
 	public final Session joinSession(final String keyword, final UUID socketId) {
 		/* Socket.IO solution */
 
-		Session session = databaseDao.getSession(keyword);
+		Session session = null;
+		try {
+			session = databaseDao.getSession(keyword);
+		} catch (NotFoundException e) {
+
+		}
 		if (null == session) {
 			userService.removeUserFromSessionBySocketId(socketId);
 
diff --git a/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java b/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
index 85ebf9d7..66d4a2aa 100644
--- a/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
+++ b/src/main/java/de/thm/arsnova/socket/ARSnovaSocketIOServer.java
@@ -112,11 +112,12 @@ public class ARSnovaSocketIOServer {
 		server.addEventListener("setSession", Session.class, new DataListener<Session>() {
 			@Override
 			public void onData(SocketIOClient client, Session session, AckRequest ackSender) {
-				sessionService.joinSession(session.getKeyword(), client.getSessionId());
-				/* active user count has to be sent to the client since the broadcast is
-				 * not always sent as long as the polling solution is active simultaneously */
-				reportActiveUserCountForSession(session.getKeyword());
-				reportSessionDataToClient(session.getKeyword(), client);
+				if (null != sessionService.joinSession(session.getKeyword(), client.getSessionId())) {
+					/* active user count has to be sent to the client since the broadcast is
+					 * not always sent as long as the polling solution is active simultaneously */
+					reportActiveUserCountForSession(session.getKeyword());
+					reportSessionDataToClient(session.getKeyword(), client);
+				}
 			}
 		});
 
-- 
GitLab