lib/SocketIOSignallingService.js
function postToFirstAvailableServer (destinationNode, signallingServers, path, message) {

        return new Promise(function (resolve, reject) {
            if (signallingServers.length === 0) {
                reject(new Utils.UnreachableError(createUnreachableErrorMessage(destinationNode)));
            }
            else {
                //noinspection JSCheckFunctionSignatures
                httpRequestService.post(url.resolve(signallingServers[0].signallingApiBase, path), message)
                    .then(resolve)
                    .catch(function (error) {
                        logger.warn("An error occurred sending signalling message using " + signallingServers[0].signallingApiBase + " trying next signalling server", error);
                        postToFirstAvailableServer(destinationNode, signallingServers.slice(1), path, message).then(resolve, reject);
                    });
            }
        });
    }
function postToFirstAvailableServer (destinationNode, signallingServers, path, message) {

        return new Promise(function (resolve, reject) {
            if (signallingServers.length === 0) {
                reject(new Utils.UnreachableError(createUnreachableErrorMessage(destinationNode)));
            }
            else {
                //noinspection JSCheckFunctionSignatures
                httpRequestService.post(url.resolve(signallingServers[0].signallingApiBase, path), message)
                    .then(resolve)
                    .catch(function (error) {
                        logger.warn("An error occurred sending signalling message using " + signallingServers[0].signallingApiBase + " trying next signalling server", error);
                        postToFirstAvailableServer(destinationNode, signallingServers.slice(1), path, message).then(resolve, reject);
                    });
            }
        });
    }
function postToFirstAvailableServer ( destinationNode , signallingServers , path , message ) { return new Promise ( function ( resolve , reject ) { if ( signallingServers . length === 0 ) { reject ( new Utils . UnreachableError ( createUnreachableErrorMessage ( destinationNode ) ) ) ; } else { //noinspection JSCheckFunctionSignatures httpRequestService . post ( url . resolve ( signallingServers [ 0 ] . signallingApiBase , path ) , message ) . then ( resolve ) . catch ( function ( error ) { logger . warn ( "An error occurred sending signalling message using " + signallingServers [ 0 ] . signallingApiBase + " trying next signalling server" , error ) ; postToFirstAvailableServer ( destinationNode , signallingServers . slice ( 1 ) , path , message ) . then ( resolve , reject ) ; } ) ; } } ) ; }
Post an object to the first available signalling server

@param destinationNode
@param signallingServers
@param path
@param message
@returns {Promise}
Post an object to the first available signalling server