You can get actual setting in api by url https://dev.pms.civana1.com/api/v1/admin/reverb
// Used packages "laravel-echo": "^2.1.6", "pusher-js": "^8.4.0"
// Example of using Echo with Reverb
window.Echo = new Echo({
broadcaster: 'reverb',
key: 'tlNfiy4gx3dSwS',
wsHost: 'ws.dev.pms.civana1.com',
wsPort: 443,
forceTLS: true,
enabledTransports: ['ws', 'wss'],
authorizer: (channel, options) => {
return {
authorize: (socketId, callback) => {
fetch('https://ws.dev.pms.civana1.com/api/broadcasting/auth', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${token}`,
'AppApiKey': `${AppApiKey}`,
'Accept': 'application/json'
},
body: JSON.stringify({
channel_name: channel.name,
socket_id: socketId,
})
})
.then(res => res.json())
.then(data => callback(null, data))
.catch(err => callback(err, null));
}
};
}
});
// Subscribe to a private channel
const channelName = `App.Models.Reservation.1`; // 1 here is reservation ID
/*
const channelName = `App.Models.Department.1`; // 1 here is department ID
const channelName = `App.Models.Guest.1`; // 1 here is guest ID
*/
window.Echo.private(channelName)
.listen('.reservation.general', (e) => {
console.log(`Received event: ${JSON.stringify(e, null, 2)}`);
})
.error((err) => {
console.log(`Error connecting to channel: ${err}`);
});
// Unsubscribe from the channel
window.Echo.leave(channelName);