Skip to content

Instantly share code, notes, and snippets.

@0xnbk
Last active August 29, 2015 14:07
Show Gist options
  • Save 0xnbk/1a2dd4b5b87c9aad3acd to your computer and use it in GitHub Desktop.
Save 0xnbk/1a2dd4b5b87c9aad3acd to your computer and use it in GitHub Desktop.
Custom Pusher implementation with Slanger
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Pusher Test</title>
<script src="//js.pusher.com/2.2/pusher.min.js"></script>
</head>
<body>
<b>Real time test - see console</b>
<script>
var pusher = new Pusher('YOUR_API_KEY', {
auth: {
headers: {
'X-CSRF-Token': 'oUqbv6jH568vMRwJoQMhu0jnBwVrbjAaF5D16ZF2',
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLsdCJhbGciOiJIUzI1NiJ9.eyJpc3dsMiOiJodsdsHRwOlwvXCds29tXC92MVwvYXV0aFwvc2lnbmdsluIiwic3ViIjoxLCJpYXQiOjE0MTM1MjIyMjgsImV4cCI6MTQxNDsdsczMTgyOH0.oatYFWsds2LRNXNZKAAle_WeEgAcJ5pX0ahC1UaOfrHr3E',
'X-Api-Key': 'a52326sfd-cd23df-457q5-adf29c-8f58819270d'
}
},
httpHost: 'your-domain.com',
httpPort: 4567,
wsHost: 'your-domain.com',
wsPort: 8080,
authEndpoint: '/v1/push/auth'
});
var channel = pusher.subscribe('private-595961413454029');
channel.bind('test-event', function(data) {
alert('An event was triggered with message: ' + data.message);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment