Author: solomax
Date: Wed Oct  5 16:44:41 2016
New Revision: 1763466

URL: http://svn.apache.org/viewvc?rev=1763466&view=rev
Log:
[OPENMEETINGS-1482] client objects are being removed on logout

Modified:
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java
    
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java
    
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
    
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
    
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/admin/connection/ConnectionsPanel.java
 Wed Oct  5 16:44:41 2016
@@ -29,7 +29,6 @@ import java.util.List;
 
 import org.apache.openmeetings.db.dao.server.ISessionManager;
 import org.apache.openmeetings.db.dao.user.IUserService;
-import org.apache.openmeetings.db.dao.user.UserDao;
 import org.apache.openmeetings.db.entity.room.Client;
 import org.apache.openmeetings.db.entity.user.User;
 import org.apache.openmeetings.web.admin.AdminPanel;
@@ -152,7 +151,7 @@ public class ConnectionsPanel extends Ad
                        protected void populateItem(final 
Item<org.apache.openmeetings.web.app.Client> item) {
                                org.apache.openmeetings.web.app.Client c = 
item.getModelObject();
                                item.add(new Label("id", ""));
-                               User u = 
getBean(UserDao.class).get(c.getUserId());
+                               User u = c.getUser();
                                item.add(new Label("login", u == null ? null : 
u.getLogin()));
                                item.add(new Label("since", 
c.getConnectedSince()));
                                item.add(new Label("scope", "html5"));

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.java
 Wed Oct  5 16:44:41 2016
@@ -35,12 +35,8 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
-import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.collections4.MapIterator;
-import org.apache.commons.collections4.keyvalue.MultiKey;
-import org.apache.commons.collections4.map.MultiKeyMap;
 import org.apache.openmeetings.IApplication;
 import org.apache.openmeetings.core.remote.MainService;
 import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
@@ -102,9 +98,9 @@ import org.wicketstuff.dashboard.web.Das
 public class Application extends AuthenticatedWebApplication implements 
IApplication {
        private static final Logger log = getLogger(Application.class, 
webAppRootKey);
        private static boolean isInstalled;
-       private static MultiKeyMap<String, 
org.apache.openmeetings.web.app.Client> ONLINE_USERS = new MultiKeyMap<>(); 
-       private static Map<String, org.apache.openmeetings.web.app.Client> 
INVALID_SESSIONS = new ConcurrentHashMap<String, 
org.apache.openmeetings.web.app.Client>();
-       private static Map<Long, Set<Client>> ROOMS = new 
ConcurrentHashMap<Long, Set<Client>>();
+       private static ConcurrentHashMap<String, Client> ONLINE_USERS = new 
ConcurrentHashMap<>(); 
+       private static ConcurrentHashMap<String, Client> INVALID_SESSIONS = new 
ConcurrentHashMap<>();
+       private static ConcurrentHashMap<Long, Set<String>> ROOMS = new 
ConcurrentHashMap<>();
        //additional maps for faster searching should be created
        private DashboardContext dashboardContext;
        private static Set<String> STRINGS_WITH_APP = new HashSet<>(); //FIXME 
need to be removed
@@ -211,30 +207,26 @@ public class Application extends Authent
                return get().dashboardContext;
        }
        
-       public synchronized static void 
addOnlineUser(org.apache.openmeetings.web.app.Client client) {
-               try {
-                       ONLINE_USERS.put("" + client.getUserId(), 
client.getSessionId(), client);
-               } catch (Exception err) {
-                       log.error("[addOnlineUser]", err);
-               }
+       public static void addOnlineUser(Client c) {
+               log.debug("Adding online client: {}, room: {}", c.getUid(), 
c.getRoomId());
+               ONLINE_USERS.put(c.getUid(), c);
        }
        
-       public synchronized static void 
removeOnlineUser(org.apache.openmeetings.web.app.Client c) {
-               try {
-                       if (c != null) {
-                               ONLINE_USERS.removeAll("" + c.getUserId(), 
c.getSessionId());
-                       }
-               } catch (Exception err) {
-                       log.error("[removeOnlineUser]", err);
+       public static void removeOnlineUser(Client c) {
+               if (c != null) {
+                       log.debug("Removing online client: {}, room: {}", 
c.getUid(), c.getRoomId());
+                       ONLINE_USERS.remove(c.getUid());
                }
        }
        
+       public static Client getOnlineClient(String uid) {
+               return uid == null ? null : ONLINE_USERS.get(uid);
+       }
+       
        public static boolean isUserOnline(Long userId) {
-               MapIterator<MultiKey<? extends String>, 
org.apache.openmeetings.web.app.Client> it = ONLINE_USERS.mapIterator();
                boolean isUserOnline = false;
-               while (it.hasNext()) {
-                       MultiKey<? extends String> multi = it.next();
-                       if (multi.size() > 0 && userId.equals(multi.getKey(0))) 
{
+               for (Map.Entry<String, Client> e : ONLINE_USERS.entrySet()) {
+                       if (e.getValue().getUserId().equals(userId)) {
                                isUserOnline = true;
                                break;
                        }
@@ -242,17 +234,15 @@ public class Application extends Authent
                return isUserOnline;
        }
 
-       public static List<org.apache.openmeetings.web.app.Client> getClients() 
{
-               return new 
ArrayList<org.apache.openmeetings.web.app.Client>(ONLINE_USERS.values());
+       public static List<Client> getClients() {
+               return new ArrayList<Client>(ONLINE_USERS.values());
        }
 
-       public static List<org.apache.openmeetings.web.app.Client> 
getClients(Long userId) {
-               List<org.apache.openmeetings.web.app.Client> result =  new 
ArrayList<org.apache.openmeetings.web.app.Client>();
-               MapIterator<MultiKey<? extends String>, 
org.apache.openmeetings.web.app.Client> it = ONLINE_USERS.mapIterator();
-               while (it.hasNext()) {
-                       MultiKey<? extends String> multi = it.next();
-                       if (multi.size() > 1 && userId.equals(multi.getKey(0))) 
{
-                               result.add(getClientByKeys(userId, 
(String)(multi.getKey(1))));
+       public static List<Client> getClients(Long userId) {
+               List<Client> result =  new ArrayList<>();
+               for (Map.Entry<String, Client> e : ONLINE_USERS.entrySet()) {
+                       if (e.getValue().getUserId().equals(userId)) {
+                               result.add(e.getValue());
                                break;
                        }
                }
@@ -263,13 +253,21 @@ public class Application extends Authent
                return ONLINE_USERS.size();
        }
        
-       public static org.apache.openmeetings.web.app.Client 
getClientByKeys(Long userId, String sessionId) {
-               return (org.apache.openmeetings.web.app.Client) 
ONLINE_USERS.get(userId, sessionId);
+       public static Client getClientByKeys(Long userId, String sessionId) {
+               Client client = null;
+               for (Map.Entry<String, Client> e : ONLINE_USERS.entrySet()) {
+                       Client c = e.getValue();
+                       if (c.getUserId().equals(userId) && 
c.getSessionId().equals(sessionId)) {
+                               client = c;
+                               break;
+                       }
+               } 
+               return client;
        }
        
        @Override
        public void invalidateClient(Long userId, String sessionId) {
-               org.apache.openmeetings.web.app.Client client = 
getClientByKeys(userId, sessionId);
+               Client client = getClientByKeys(userId, sessionId);
                if (client != null) {
                        if 
(!INVALID_SESSIONS.containsKey(client.getSessionId())) {
                                INVALID_SESSIONS.put(client.getSessionId(), 
client);
@@ -283,60 +281,52 @@ public class Application extends Authent
        }
        
        public static void removeInvalidSession(String sessionId) {
-               if (INVALID_SESSIONS.containsKey(sessionId)){
+               if (sessionId != null){
                        INVALID_SESSIONS.remove(sessionId);
                }
        }
        
-       public static Client addUserToRoom(long roomId, int pageId) {
-               if (!ROOMS.containsKey(roomId)) {
-                       ROOMS.put(roomId, new ConcurrentHashSet<Client>());
-               }
-               Client c = new Client(WebSession.get().getId(), pageId, 
WebSession.getUserId());
-               c.setUid(UUID.randomUUID().toString());
-               ROOMS.get(roomId).add(c);
+       public static Client addUserToRoom(Client c) {
+               log.debug("Adding online room client: {}, room: {}", 
c.getUid(), c.getRoomId());
+               ROOMS.putIfAbsent(c.getRoomId(), new 
ConcurrentHashSet<String>());
+               ROOMS.get(c.getRoomId()).add(c.getUid());
                return c;
        }
        
-       public static void removeUserFromRoom(long roomId, int pageId) {
-               removeUserFromRoom(roomId, new Client(WebSession.get().getId(), 
pageId, WebSession.getUserId()));
-       }
-       
-       public static Client removeUserFromRoom(long roomId, Client _c) {
-               if (ROOMS.containsKey(roomId)) {
-                       Set<Client> clients = ROOMS.get(roomId);
-                       for (Client c : clients) {
-                               if (c.equals(_c)) {
-                                       clients.remove(c);
-                                       return c;
-                               }
-                       }
-                       if (clients.isEmpty()) {
-                               ROOMS.remove(roomId);
+       public static Client removeUserFromRoom(Client c) {
+               log.debug("Removing online room client: {}, room: {}", 
c.getUid(), c.getRoomId());
+               if (c.getRoomId() != null) {
+                       Set<String> clients = ROOMS.get(c.getRoomId());
+                       if (clients != null) {
+                               clients.remove(c.getUid());
+                               c.setRoomId(null);
                        }
                }
-               return _c;
+               return c;
        }
        
-       public static long getRoom(Client c) {
-               for (Entry<Long, Set<Client>> me : ROOMS.entrySet()) {
-                       Set<Client> clients = me.getValue();
-                       if (clients.contains(c)) {
-                               return me.getKey();
+       public static List<Client> getRoomClients(Long roomId) {
+               List<Client> clients = new ArrayList<>();
+               if (roomId != null) {
+                       Set<String> uids = ROOMS.get(roomId);
+                       if (uids != null) {
+                               for (String uid : uids) {
+                                       Client c = getOnlineClient(uid);
+                                       if (c != null) {
+                                               clients.add(c);
+                                       }
+                               }
                        }
                }
-               return -1;
-       }
-       
-       public static Set<Client> getRoomUsers(long roomId) {
-               return ROOMS.containsKey(roomId) ? ROOMS.get(roomId) : new 
HashSet<Client>();
+               return clients;
        }
        
-       public static Set<Long> getUserRooms(long userId) {
-               Set<Long> result = new HashSet<Long>();
-               for (Entry<Long, Set<Client>> me : ROOMS.entrySet()) {
-                       for (Client c : me.getValue()) {
-                               if (c.getUserId() == userId) {
+       public static Set<Long> getUserRooms(Long userId) {
+               Set<Long> result = new HashSet<>();
+               for (Entry<Long, Set<String>> me : ROOMS.entrySet()) {
+                       for (String uid : me.getValue()) {
+                               Client c = getOnlineClient(uid);
+                               if (c != null && c.getUserId().equals(userId)) {
                                        result.add(me.getKey());
                                }
                        }
@@ -345,10 +335,10 @@ public class Application extends Authent
        }
        
        public static boolean isUserInRoom(long roomId, long userId) {
-               if (ROOMS.containsKey(roomId)) {
-                       Set<Client> clients = ROOMS.get(roomId);
-                       for (Client c : clients) {
-                               if (c.getUserId() == userId) {
+               Set<String> clients = ROOMS.get(roomId);
+               if (clients != null) {
+                       for (String uid : clients) {
+                               if 
(getOnlineClient(uid).getUserId().equals(userId)) {
                                        return true;
                                }
                        }

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
 Wed Oct  5 16:44:41 2016
@@ -18,11 +18,17 @@
  */
 package org.apache.openmeetings.web.app;
 
+import static org.apache.openmeetings.web.app.Application.getBean;
+
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.UUID;
 
+import org.apache.openmeetings.db.dao.user.UserDao;
 import org.apache.openmeetings.db.entity.IDataProviderEntity;
+import org.apache.openmeetings.db.entity.room.Room.Right;
+import org.apache.openmeetings.db.entity.user.User;
 import org.apache.wicket.protocol.ws.api.registry.IKey;
 
 /**
@@ -33,116 +39,121 @@ import org.apache.wicket.protocol.ws.api
 public class Client implements IDataProviderEntity {
        private static final long serialVersionUID = 1L;
 
-       public enum Right {
-               moderator
-       }
-       private String sessionId;
+       private final String sessionId;
        private int pageId;
-       private long userId;
-       private String uid;
-       private Set<Right> rights = new HashSet<Right>();
-       private Date connectedSince;
+       private final User user;
+       private Long roomId;
+       private final String uid;
+       private final Set<Right> rights = new HashSet<>();
+       private final Date connectedSince;
 
-       public Client() {
-               this.connectedSince = new Date();
+       public Client(String sessionId, Long userId) {
+               this(sessionId, 0, userId);
        }
        
-       public Client(String sessionId, IKey key, long userId) {
-               this(sessionId, key.hashCode(), userId);
-       }
-       
-       public Client(String sessionId, int pageId, long userId) {
+       public Client(String sessionId, int pageId, Long userId) {
                this.sessionId = sessionId;
                this.pageId = pageId;
-               this.userId = userId;
+               this.user = getBean(UserDao.class).get(userId);
                this.connectedSince = new Date();
+               uid = UUID.randomUUID().toString();
        }
 
        public String getSessionId() {
                return sessionId;
        }
 
-       public void setSessionId(String sessionId) {
-               this.sessionId = sessionId;
-       }
-
        public int getPageId() {
                return pageId;
        }
 
+       public Client setPageId(IKey key) {
+               this.pageId = key.hashCode();
+               return this;
+       }
+
        public void setPageId(int pageId) {
                this.pageId = pageId;
        }
 
-       public long getUserId() {
-               return userId;
+       public User getUser() {
+               return user;
        }
 
-       public void setUserId(long userId) {
-               this.userId = userId;
+       public Long getUserId() {
+               return user.getId();
        }
 
        public String getUid() {
                return uid;
        }
 
-       public void setUid(String uid) {
-               this.uid = uid;
+       public Set<Right> getRights() {
+               return rights;
+       }
+
+       public boolean hasRight(Right right) {
+               if (Right.superModerator == right) {
+                       return rights.contains(right);
+               }
+               return rights.contains(Right.superModerator) || 
rights.contains(Right.moderator) ? true : rights.contains(right);
+       }
+
+       public Date getConnectedSince() {
+               return connectedSince;
+       }
+
+       @Override
+       public Long getId() {
+               return null;
+       }
+
+       @Override
+       public void setId(Long id) {
+       }
+
+       public Long getRoomId() {
+               return roomId;
+       }
+
+       public Client setRoomId(Long roomId) {
+               this.roomId = roomId;
+               return this;
        }
 
        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
-               result = prime * result + pageId;
-               result = prime * result + ((sessionId == null) ? 0 : 
sessionId.hashCode());
-               result = prime * result + (int) (userId ^ (userId >>> 32));
+               result = prime * result + ((uid == null) ? 0 : uid.hashCode());
                return result;
        }
 
        @Override
        public boolean equals(Object obj) {
-               if (this == obj)
+               if (this == obj) {
                        return true;
-               if (obj == null)
+               }
+               if (obj == null) {
                        return false;
-               if (getClass() != obj.getClass())
+               }
+               if (!(obj instanceof Client)) {
                        return false;
+               }
                Client other = (Client) obj;
-               if (pageId != other.pageId)
-                       return false;
-               if (sessionId == null) {
-                       if (other.sessionId != null)
+               if (uid == null) {
+                       if (other.uid != null) {
                                return false;
-               } else if (!sessionId.equals(other.sessionId))
-                       return false;
-               if (userId != other.userId)
+                       }
+               } else if (!uid.equals(other.uid)) {
                        return false;
+               }
                return true;
        }
 
-       public Set<Right> getRights() {
-               return rights;
-       }
-
-       public boolean hasRight(Right right) {
-               return rights.contains(Right.moderator) ? true : 
rights.contains(right);
-       }
-
-       public Date getConnectedSince() {
-               return connectedSince;
-       }
-
-       public void setConnectedSince(Date connectedSince) {
-               this.connectedSince = connectedSince;
-       }
-
        @Override
-       public Long getId() {
-               return null;
-       }
-
-       @Override
-       public void setId(Long id) {
+       public String toString() {
+               return "Client [uid=" + uid + ", sessionId=" + sessionId + ", 
pageId=" + pageId + ", userId=" + user.getId() + ", roomId=" + roomId
+                               + ", rights=" + rights + ", connectedSince=" + 
connectedSince + "]";
        }
 }

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 Wed Oct  5 16:44:41 2016
@@ -114,7 +114,7 @@ public class WebSession extends Abstract
 
        @Override
        public void invalidate() {
-               removeOnlineUser(getClientByKeys(getUserId(), get().getId()));
+               removeOnlineUser(getClientByKeys(userId, getId()));
                super.invalidate();
                userId = null;
                rights = 
Collections.unmodifiableSet(Collections.<Right>emptySet());
@@ -268,7 +268,7 @@ public class WebSession extends Abstract
                if (_roomId != null) {
                        roomId = _roomId;
                }
-               if (i != null) {
+               if (_i != null) {
                        i = _i;
                }
                userId = u.getId();

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/MainPanel.java
 Wed Oct  5 16:44:41 2016
@@ -21,7 +21,6 @@ package org.apache.openmeetings.web.comm
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
 import static org.apache.openmeetings.web.app.Application.addOnlineUser;
 import static org.apache.openmeetings.web.app.Application.getBean;
-import static org.apache.openmeetings.web.app.Application.getClientByKeys;
 import static org.apache.openmeetings.web.app.Application.removeOnlineUser;
 import static org.apache.openmeetings.web.app.WebSession.getUserId;
 import static 
org.apache.openmeetings.web.util.CallbackFunctionHelper.getNamedFunction;
@@ -68,6 +67,8 @@ import org.apache.wicket.markup.html.pan
 import org.apache.wicket.markup.html.panel.Panel;
 import org.apache.wicket.model.CompoundPropertyModel;
 import org.apache.wicket.protocol.ws.api.WebSocketBehavior;
+import org.apache.wicket.protocol.ws.api.message.AbortedMessage;
+import org.apache.wicket.protocol.ws.api.message.AbstractClientMessage;
 import org.apache.wicket.protocol.ws.api.message.ClosedMessage;
 import org.apache.wicket.protocol.ws.api.message.ConnectedMessage;
 import org.red5.logging.Red5LoggerFactory;
@@ -81,7 +82,7 @@ public class MainPanel extends Panel {
        private static final long serialVersionUID = 1L;
        private static final Logger log = 
Red5LoggerFactory.getLogger(MainPanel.class, webAppRootKey);
        public final static String PARAM_USER_ID = "userId";
-       private Client client;
+       private Client client = null;
        private final MenuPanel menu;
        private final WebMarkupContainer topControls = new 
WebMarkupContainer("topControls");
        private final WebMarkupContainer topLinks = new 
WebMarkupContainer("topLinks");
@@ -96,7 +97,6 @@ public class MainPanel extends Panel {
 
        public MainPanel(String id, WebMarkupContainer panel) {
                super(id);
-               client = new Client();
                
add(topControls.setOutputMarkupPlaceholderTag(true).setMarkupId("topControls"));
                menu = new MenuPanel("menu", getMainMenu());
                contents = new WebMarkupContainer("contents");
@@ -200,18 +200,29 @@ public class MainPanel extends Panel {
                        private static final long serialVersionUID = 1L;
 
                        @Override
-                       protected void onConnect(ConnectedMessage message) {
-                               super.onConnect(message);
-                               addOnlineUser(new 
Client(message.getSessionId(), message.getKey(), getUserId()));
-                               
log.debug(String.format("WebSocketBehavior::onConnect [session: %s, key: %s]", 
message.getSessionId(), message.getKey()));
+                       protected void onConnect(ConnectedMessage msg) {
+                               super.onConnect(msg);
+                               client = new Client(getSession().getId(), 
msg.getKey().hashCode(), getUserId());
+                               addOnlineUser(client);
+                               log.debug("WebSocketBehavior::onConnect [uid: 
{}, session: {}, key: {}]", client.getUid(), msg.getSessionId(), msg.getKey());
+                       }
+
+                       @Override
+                       protected void onAbort(AbortedMessage msg) {
+                               super.onAbort(msg);
+                               closeHandler(msg);
                        }
                        
                        @Override
-                       protected void onClose(ClosedMessage message) {
-                               Client client = getClientByKeys(getUserId(), 
WebSession.get().getId());
+                       protected void onClose(ClosedMessage msg) {
+                               super.onClose(msg);
+                               closeHandler(msg);
+                       }
+
+                       private void closeHandler(AbstractClientMessage msg) {
+                               log.debug("WebSocketBehavior::closeHandler 
[uid: {}, session: {}, key: {}]", client.getUid(), msg.getSessionId(), 
msg.getKey());
                                removeOnlineUser(client);
-                               super.onClose(message);
-                               log.debug("WebSocketBehavior::onClose");
+                               client = null;
                        }
                });
        }
@@ -228,7 +239,7 @@ public class MainPanel extends Panel {
                                        public void onClick(AjaxRequestTarget 
target) {
                                                onClick(MainPanel.this, target);
                                        }
-                               }); 
+                               });
                        }
                        menu.add(new 
MenuItem(Application.getString(gl.getLabelId()), l));
                }

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/SwfPanel.java
 Wed Oct  5 16:44:41 2016
@@ -20,7 +20,7 @@ package org.apache.openmeetings.web.room
 
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
 import static org.apache.openmeetings.web.app.Application.getBean;
-import static org.apache.openmeetings.web.app.Application.getRoomUsers;
+import static org.apache.openmeetings.web.app.Application.getRoomClients;
 import static org.apache.openmeetings.web.app.WebSession.WICKET_ROOM_ID;
 import static org.apache.openmeetings.web.app.WebSession.getLanguage;
 import static org.apache.openmeetings.web.app.WebSession.getSid;
@@ -39,6 +39,7 @@ import org.apache.openmeetings.db.dao.ro
 import org.apache.openmeetings.db.dao.room.RoomDao;
 import org.apache.openmeetings.db.dao.server.ServerDao;
 import org.apache.openmeetings.db.dao.server.SessiondataDao;
+import org.apache.openmeetings.db.entity.room.Room;
 import org.apache.openmeetings.db.entity.room.Client;
 import org.apache.openmeetings.db.entity.server.Server;
 import org.apache.openmeetings.web.app.Application;
@@ -208,8 +209,8 @@ public class SwfPanel extends BasePanel
        }
 
        public static boolean isModerator(long userId, long roomId) {
-               for (org.apache.openmeetings.web.app.Client c : 
getRoomUsers(roomId)) {
-                       if (c.getUserId() == userId && 
c.hasRight(org.apache.openmeetings.web.app.Client.Right.moderator)) {
+               for (org.apache.openmeetings.web.app.Client c : 
getRoomClients(roomId)) {
+                       if (c.getUserId() == userId && 
c.hasRight(Room.Right.moderator)) {
                                return true;
                        }
                }

Modified: 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java
 (original)
+++ 
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/ChatPanel.java
 Wed Oct  5 16:44:41 2016
@@ -21,7 +21,7 @@ package org.apache.openmeetings.web.user
 import static 
org.apache.openmeetings.util.OpenmeetingsVariables.CONFIG_DASHBOARD_SHOW_CHAT;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
 import static org.apache.openmeetings.web.app.Application.getBean;
-import static org.apache.openmeetings.web.app.Application.getRoomUsers;
+import static org.apache.openmeetings.web.app.Application.getRoomClients;
 import static org.apache.openmeetings.web.app.Application.getUserRooms;
 import static org.apache.openmeetings.web.app.Application.isUserInRoom;
 import static org.apache.openmeetings.web.app.WebSession.getDateFormat;
@@ -223,9 +223,9 @@ public class ChatPanel extends BasePanel
        
        private static void sendRoom(ChatMessage m, String msg) {
                IWebSocketConnectionRegistry reg = 
WebSocketSettings.Holder.get(Application.get()).getConnectionRegistry();
-               for (Client c : getRoomUsers(m.getToRoom().getId())) {
+               for (Client c : getRoomClients(m.getToRoom().getId())) {
                        try {
-                               if (!m.isNeedModeration() || 
(m.isNeedModeration() && c.hasRight(Client.Right.moderator))) {
+                               if (!m.isNeedModeration() || 
(m.isNeedModeration() && c.hasRight(Room.Right.moderator))) {
                                        IWebSocketConnection con = 
reg.getConnection(Application.get(), c.getSessionId(), new 
PageIdKey(c.getPageId()));
                                        if (con != null) {
                                                con.sendMessage(msg);

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
 Wed Oct  5 16:44:41 2016
@@ -19,6 +19,7 @@
 package org.apache.openmeetings.web.app;
 
 import static org.apache.openmeetings.web.app.Application.getBean;
+
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;

Modified: 
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 (original)
+++ 
openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 Wed Oct  5 16:44:41 2016
@@ -115,7 +115,7 @@ public class WebSession extends Abstract
 
        @Override
        public void invalidate() {
-               removeOnlineUser(getClientByKeys(getUserId(), get().getId()));
+               removeOnlineUser(getClientByKeys(userId, getId()));
                super.invalidate();
                userId = null;
                rights = 
Collections.unmodifiableSet(Collections.<Right>emptySet());

Modified: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Client.java
 Wed Oct  5 16:44:41 2016
@@ -19,6 +19,7 @@
 package org.apache.openmeetings.web.app;
 
 import static org.apache.openmeetings.web.app.Application.getBean;
+
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;

Modified: 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
URL: 
http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java?rev=1763466&r1=1763465&r2=1763466&view=diff
==============================================================================
--- 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 (original)
+++ 
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/WebSession.java
 Wed Oct  5 16:44:41 2016
@@ -115,7 +115,7 @@ public class WebSession extends Abstract
 
        @Override
        public void invalidate() {
-               removeOnlineUser(getClientByKeys(getUserId(), get().getId()));
+               removeOnlineUser(getClientByKeys(userId, getId()));
                super.invalidate();
                userId = null;
                rights = 
Collections.unmodifiableSet(Collections.<Right>emptySet());


Reply via email to