Created
September 25, 2010 20:02
-
-
Save seungjin/597235 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<!-- http://faye.jcoglan.com/browser.html --> | |
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'> | |
</script> | |
<script type="text/javascript" src="http://localhost:8000/faye.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
var client = new Faye.Client("http://localhost:8000/faye"); | |
var subscription = client.subscribe('/email/new', function(msg){alert(msg.text);}); | |
}) | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
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
// http://faye.jcoglan.com/node.html | |
var http = require('http'); | |
var faye = require('faye'); | |
var bayeux = new faye.NodeAdapter({ | |
mount: '/faye', | |
timeout: 45 | |
}); | |
// Handle non-Bayeux requests | |
var server = http.createServer(function(request,response) { | |
var currentTime = new Date(); | |
console.log("non-Bayeux request received at " + currentTime + " " + request); | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
response.write('non-Bayeux request'); | |
response.end(); | |
}); | |
bayeux.attach(server); | |
server.listen(8000); |
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
// http://faye.jcoglan.com/node.html | |
var http = require('http'); | |
var faye = require('faye'); | |
var client = new faye.Client('http://localhost:8000/faye'); | |
client.publish('/email/new', {text: "new mail arrived"}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment