lib/RedundantSignallingSocket.js
function connectToServers() {
        var knownServers = signallingServerSelector.getServerSpecsInPriorityOrder();

        for (var i = 0; i < knownServers.length; i++) {
            var connectionsRemaining = signallingServerService.getPreferredNumberOfSockets() - Object.keys(connectedSockets).length;

            //
            // We have enough connections
            //
            if (connectionsRemaining === 0) {
                break;
            }

            //
            // Try to connect to a new server
            //
            var serverSpec = knownServers[i];
            if (!currentlyConnectedToServer(serverSpec)) {
                var socket;
                try {
                    socket = socketFactory.createSocket(serverSpec);
                    storeSocket(serverSpec, socket);
                    addListeners(socket, serverSpec);
                    loggingService.info("Attempting to connect to signalling server (" + serverSpec.signallingApiBase + ")");
                }
                catch (error) {
                    loggingService.error("Error connecting to socket " + serverSpec.signallingApiBase, error);
                }
            }
        }

        //
        // Store the new set of connected servers in session storage so we
        // can prefer them in the event of a reload
        //
        signallingServerSelector.setLastConnectedServers(getListOfCurrentSignallingApiBases());
    }
function connectToServers() {
        var knownServers = signallingServerSelector.getServerSpecsInPriorityOrder();

        for (var i = 0; i < knownServers.length; i++) {
            var connectionsRemaining = signallingServerService.getPreferredNumberOfSockets() - Object.keys(connectedSockets).length;

            //
            // We have enough connections
            //
            if (connectionsRemaining === 0) {
                break;
            }

            //
            // Try to connect to a new server
            //
            var serverSpec = knownServers[i];
            if (!currentlyConnectedToServer(serverSpec)) {
                var socket;
                try {
                    socket = socketFactory.createSocket(serverSpec);
                    storeSocket(serverSpec, socket);
                    addListeners(socket, serverSpec);
                    loggingService.info("Attempting to connect to signalling server (" + serverSpec.signallingApiBase + ")");
                }
                catch (error) {
                    loggingService.error("Error connecting to socket " + serverSpec.signallingApiBase, error);
                }
            }
        }

        //
        // Store the new set of connected servers in session storage so we
        // can prefer them in the event of a reload
        //
        signallingServerSelector.setLastConnectedServers(getListOfCurrentSignallingApiBases());
    }
function connectToServers ( ) { var knownServers = signallingServerSelector . getServerSpecsInPriorityOrder ( ) ; for ( var i = 0 ; i < knownServers . length ; i ++ ) { var connectionsRemaining = signallingServerService . getPreferredNumberOfSockets ( ) - Object . keys ( connectedSockets ) . length ; // // We have enough connections // if ( connectionsRemaining === 0 ) { break ; } // // Try to connect to a new server // var serverSpec = knownServers [ i ] ; if ( ! currentlyConnectedToServer ( serverSpec ) ) { var socket ; try { socket = socketFactory . createSocket ( serverSpec ) ; storeSocket ( serverSpec , socket ) ; addListeners ( socket , serverSpec ) ; loggingService . info ( "Attempting to connect to signalling server (" + serverSpec . signallingApiBase + ")" ) ; } catch ( error ) { loggingService . error ( "Error connecting to socket " + serverSpec . signallingApiBase , error ) ; } } } // // Store the new set of connected servers in session storage so we // can prefer them in the event of a reload // signallingServerSelector . setLastConnectedServers ( getListOfCurrentSignallingApiBases ( ) ) ; }
Connect to servers if we're not connected to enough
Connect to servers if we re not connected to enough