Onja
1 year ago
1 changed files with 44 additions and 0 deletions
@ -0,0 +1,44 @@ |
|||
const emitter = require('../services/eventEmitter'); |
|||
|
|||
const configure = (socket) => { |
|||
// Create a new listener for the download.start event
|
|||
emitter.on('download.start', ({ url, filepath }) => { |
|||
socket.emit('download.start', { message: 'Début de téléchargement' }); |
|||
}); |
|||
|
|||
// Create a new listener for the download.end event
|
|||
emitter.on('download.end', ({ url, filepath }) => { |
|||
socket.emit('download.end', { message: 'Téléchargement terminé' }); |
|||
}); |
|||
|
|||
// Create a new listener for the download.error event
|
|||
emitter.on('download.error', ({ url, filepath, error, type }) => { |
|||
socket.emit('download.error', { error, type, message: 'Erreur lors du téléchargement' }); |
|||
}); |
|||
|
|||
// Create a new listener for the download.progress event
|
|||
emitter.on('download.progress', ({ url, filepath, downloaded }) => { |
|||
downloaded = (Math.floor(downloaded / 1024 / 1024 * 100) / 100).toLocaleString(); |
|||
socket.emit('download.progress', { downloaded, message: `[${downloaded} Mo] téléchargés` }); |
|||
}); |
|||
|
|||
|
|||
|
|||
|
|||
// Create a new listener for the parse start event
|
|||
emitter.on('parse.start', ({ filepath, columns, headers, result }) => { |
|||
socket.emit('parse.start', { message: 'Début de traitement' }); |
|||
}); |
|||
|
|||
// Create a new listener for the parse.end event
|
|||
emitter.on('parse.end', ({ filepath, columns, count }) => { |
|||
socket.emit('parse.end', { message: 'Traitement terminé' }); |
|||
}); |
|||
|
|||
// Create a new listener for the parse.error event
|
|||
emitter.on('parse.error', ({ filepath, columns, error }) => { |
|||
socket.emit('parse.error', { message: 'Erreur lors du traitement' }); |
|||
}); |
|||
} |
|||
|
|||
module.exports = configure; |
Loading…
Reference in new issue