Created
April 30, 2013 09:37
-
-
Save ajtrichards/5487672 to your computer and use it in GitHub Desktop.
Faye PUB/SUB server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://localhost:8000/faye/client.js"></script> | |
<script type="text/javascript"> | |
/* | |
** Script to handle notifications | |
*/ | |
var client = new Faye.Client('http://localhost:8000/faye',{ | |
timeout: 120 | |
}); | |
client.subscribe('/messages', function(message){ | |
alert('We got a message: ' + message.text); | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var faye = require('faye'), | |
fayeRedis = require('faye-redis'); | |
var server = new faye.NodeAdapter({ | |
mount: '/faye', | |
timeout: 45 | |
}); | |
server.listen(8000); | |
server.bind('handshake', function (client_id){ | |
console.log('Handshake: ' + client_id); | |
}); | |
server.bind('subscribe', function (client_id, channel){ | |
console.log('Subscribe: ' + client_id + ', Channel: ' + channel); | |
}); | |
server.bind('publish', function(client_id, channel, data){ | |
console.log('C: ' + client_id + ', Chan: ' + channel); | |
console.log(data); | |
}); | |
server.bind('disconnect', function(client_id){ | |
console.log('disconnected: ' + client_id); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment