2023-07-25 17:23:48 +02:00
|
|
|
import Pusher from 'pusher-js';
|
|
|
|
import Echo from 'laravel-echo';
|
2023-10-16 15:41:37 +02:00
|
|
|
import {useToast} from 'vue-toastification';
|
|
|
|
|
|
|
|
const toast = useToast();
|
2023-07-25 17:23:48 +02:00
|
|
|
|
|
|
|
window.Pusher = Pusher;
|
2023-10-16 15:41:37 +02:00
|
|
|
|
|
|
|
function handleJobEvent(event, type = 'success') {
|
|
|
|
if (event.message) {
|
|
|
|
toast[type](event.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var echo = new Echo({
|
2023-07-25 17:23:48 +02:00
|
|
|
broadcaster: 'pusher',
|
|
|
|
key: 'adremakey',
|
|
|
|
wsHost: window.location.hostname,
|
2023-08-15 15:07:55 +02:00
|
|
|
wsPort: 80,
|
|
|
|
wssPort: 443,
|
2023-07-25 17:23:48 +02:00
|
|
|
forceTLS: false,
|
|
|
|
disableStats: true,
|
|
|
|
cluster: 'adrema',
|
|
|
|
enabledTransports: ['ws', 'wss'],
|
|
|
|
});
|
2023-10-16 15:41:37 +02:00
|
|
|
|
|
|
|
echo.channel('jobs')
|
|
|
|
.listen('\\App\\Lib\\Events\\JobStarted', (e) => handleJobEvent(e, 'success'))
|
|
|
|
.listen('\\App\\Lib\\Events\\JobFinished', (e) => handleJobEvent(e, 'success'))
|
|
|
|
.listen('\\App\\Lib\\Events\\JobFailed', (e) => handleJobEvent(e, 'error'));
|
|
|
|
|
|
|
|
export default echo;
|