function pushConstraints(constraints, param = config) {
    let emitterConstraints = new EventEmitter();
    portSocket = param.portSocket;
    addressWarehouse = param.warehouseAddress;
    urlSocket = `http://${addressWarehouse}:${portSocket}`;
    handshake(param).then(() => {
        let socket = io.connect(urlSocket);
        let msg = messageBuilder(constraints, 'pushConstraints');
        socket.on('connect', function () {
            socket.emit('pushConstraints', msg);
        })
            .on('resultsConstraints', (messageResults) => {
            if (messageResults.value === 'found') {
                logger_1.logger.log('info', `Job trace found in Warehouse`);
                logger_1.logger.log('debug', `Message receive from server (check constraints) \n ${JSON.stringify(messageResults)}`);
                let workPath = messageResults.data[0].workDir;
                fStdout_fSterr_Check(workPath).on('checkOK', (nameOut, nameErr) => {
                    logger_1.logger.log('success', `Found ${messageResults.data.length} jobs traces`);
                    emitterConstraints.emit('foundDocs', nameOut, nameErr, workPath);
                })
                    .on('checkNotOK', () => {
                    emitterConstraints.emit('notFoundDocs');
                });
            }
            ;
            if (messageResults.value === 'notFound') {
                logger_1.logger.log('info', `Job trace not found in Warehouse`);
                logger_1.logger.log('debug', `Message receive from server (check constraints) \n ${JSON.stringify(messageResults)}`);
                emitterConstraints.emit('notFoundDocs', messageResults);
            }
            if (messageResults.value === 'errorConstraints')
                emitterConstraints.emit('errorDocs', messageResults);
        });
    })
        .catch(() => {
        emitterConstraints.emit('cantConnect');
    });
    return emitterConstraints;
}
function pushConstraints(constraints, param = config) {
    let emitterConstraints = new EventEmitter();
    portSocket = param.portSocket;
    addressWarehouse = param.warehouseAddress;
    urlSocket = `http:
    handshake(param).then(() => {
        let socket = io.connect(urlSocket);
        let msg = messageBuilder(constraints, 'pushConstraints');
        socket.on('connect', function () {
            socket.emit('pushConstraints', msg);
        })
            .on('resultsConstraints', (messageResults) => {
            if (messageResults.value === 'found') {
                logger_1.logger.log('info', `Job trace found in Warehouse`);
                logger_1.logger.log('debug', `Message receive from server (check constraints) \n ${JSON.stringify(messageResults)}`);
                let workPath = messageResults.data[0].workDir;
                fStdout_fSterr_Check(workPath).on('checkOK', (nameOut, nameErr) => {
                    logger_1.logger.log('success', `Found ${messageResults.data.length} jobs traces`);
                    emitterConstraints.emit('foundDocs', nameOut, nameErr, workPath);
                })
                    .on('checkNotOK', () => {
                    emitterConstraints.emit('notFoundDocs');
                });
            }
            ;
            if (messageResults.value === 'notFound') {
                logger_1.logger.log('info', `Job trace not found in Warehouse`);
                logger_1.logger.log('debug', `Message receive from server (check constraints) \n ${JSON.stringify(messageResults)}`);
                emitterConstraints.emit('notFoundDocs', messageResults);
            }
            if (messageResults.value === 'errorConstraints')
                emitterConstraints.emit('errorDocs', messageResults);
        });
    })
        .catch(() => {
        emitterConstraints.emit('cantConnect');
    });
    return emitterConstraints;
}
function pushConstraints ( constraints , param = config ) { let emitterConstraints = new EventEmitter ( ) ; portSocket = param . portSocket ; addressWarehouse = param . warehouseAddress ; urlSocket = ` ${ addressWarehouse } ${ portSocket } ` ; handshake ( param ) . then ( ( ) => { let socket = io . connect ( urlSocket ) ; let msg = messageBuilder ( constraints , 'pushConstraints' ) ; socket . on ( 'connect' , function ( ) { socket . emit ( 'pushConstraints' , msg ) ; } ) . on ( 'resultsConstraints' , ( messageResults ) => { if ( messageResults . value === 'found' ) { logger_1 . logger . log ( 'info' , ` ` ) ; logger_1 . logger . log ( 'debug' , ` \n ${ JSON . stringify ( messageResults ) } ` ) ; let workPath = messageResults . data [ 0 ] . workDir ; fStdout_fSterr_Check ( workPath ) . on ( 'checkOK' , ( nameOut , nameErr ) => { logger_1 . logger . log ( 'success' , ` ${ messageResults . data . length } ` ) ; emitterConstraints . emit ( 'foundDocs' , nameOut , nameErr , workPath ) ; } ) . on ( 'checkNotOK' , ( ) => { emitterConstraints . emit ( 'notFoundDocs' ) ; } ) ; } ; if ( messageResults . value === 'notFound' ) { logger_1 . logger . log ( 'info' , ` ` ) ; logger_1 . logger . log ( 'debug' , ` \n ${ JSON . stringify ( messageResults ) } ` ) ; emitterConstraints . emit ( 'notFoundDocs' , messageResults ) ; } if ( messageResults . value === 'errorConstraints' ) emitterConstraints . emit ( 'errorDocs' , messageResults ) ; } ) ; } ) . catch ( ( ) => { emitterConstraints . emit ( 'cantConnect' ) ; } ) ; return emitterConstraints ; }
/*
function push that send a message inside the socket connection to the warehouse server
@constraints : constraints send to the warehouse for checking.
#socket : socket client connection on adress.
#msg : message passed inside the socket connection, using the messageBuilder fonction
/ * function push that send a message inside the socket connection to the warehouse server