Skip to content
Snippets Groups Projects
Commit 50a9ccc4 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Using Set instead of List as Collection type for getUsersInSession to

prevent duplicates if the client uses Socket.IO and still sends the
**/online ping.
parent fb81028f
Branches
Tags
No related merge requests found
......@@ -39,7 +39,7 @@ public interface IUserService {
boolean isUserInSession(User user, String keyword);
List<User> getUsersInSession(String keyword);
Set<User> getUsersInSession(String keyword);
void addCurrentUserToSessionMap(String keyword);
......
......@@ -7,7 +7,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
......@@ -148,8 +148,8 @@ public class UserService implements IUserService, InitializingBean, DisposableBe
}
@Override
public List<User> getUsersInSession(String keyword) {
List<User> result = new ArrayList<User>();
public Set<User> getUsersInSession(String keyword) {
Set<User> result = new HashSet<User>();
for (Entry<User, String> e : user2session.entrySet()) {
if (e.getValue().equals(keyword)) {
result.add(e.getKey());
......
......@@ -265,7 +265,7 @@ public class ARSnovaSocketIOServer {
* all connected clients and if send feedback, if user is in current
* session
*/
List<User> users = userService.getUsersInSession(sessionKey);
Set<User> users = userService.getUsersInSession(sessionKey);
for (SocketIOClient c : server.getAllClients()) {
User u = userService.getUser2SocketId(c.getSessionId());
......
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