All Downloads are FREE. Search and download functionalities are using the official Maven repository.

angularBeans.realtime.GlobalConnectionHolder Maven / Gradle / Ivy

There is a newer version: 1.0.2-RELEASE
Show newest version
/*
 * AngularBeans, CDI-AngularJS bridge 
 *
 * Copyright (c) 2014, Bessem Hmidi. or third-party contributors as
 * indicated by the @author tags or express copyright attribution
 * statements applied by the authors.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 */
package angularBeans.realtime;

import java.util.HashSet;
import java.util.Set;

import javax.enterprise.context.ApplicationScoped;

import org.projectodd.sockjs.SockJsConnection;

import angularBeans.context.SessionMapper;

/**
 * this is a holder for all sockJs opened sessions
 * 
 * @author Bassem Hmidi
 *
 */

@ApplicationScoped
public class GlobalConnectionHolder {

	Set allConnections = new HashSet();

	public Set getAllConnections() {
		return allConnections;
	}

	public void removeConnection(String id) {
		
		
		for(SockJsConnection connection:new HashSet<>(allConnections)){
			String httpSessionId=SessionMapper.getHTTPSessionID(connection.id);
			if(httpSessionId!=null){
			if(httpSessionId.equals(id)){
			SessionMapper.getSessionsMap().remove(id);
			
			try {
				connection.destroy();
				
			} catch (Exception e) {
			
			}
		
			
			
			allConnections.remove(connection);
			}
			}
		}
		
		
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy