I use Pusher.com to set up real time notification. I rather use it for real time table sync.
But sometimes, it doesn't work well due to connection issue. So I want to check if pusher connect is active or not. I'm using Laravel for this system and I displayed the status with icon(Green and red icon).
Here is the code what I written in blade.php file
var pusher = new Pusher('dfgfg', {
cluster: 'us3',
encrypted: true
});
pusher.connection.bind('connected', function() {
$('#pusheron').css('display','flex');
$('#pusheroff').css('display','none');
});
pusher.connection.bind('error', function() {
$('#pusheron').css('display','none');
$('#pusheroff').css('display','flex');
});
This is what I've done now. But it sometimes doesn't work correctly. I would be glad if someone teach me other way to get pusher connection status in real time. Regards