Created
June 10, 2014 16:48
-
-
Save gs-akhan/e326f678578946cde0c6 to your computer and use it in GitHub Desktop.
busio testing
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
//Server | |
var express = require('express'); | |
var fs = require('fs'); | |
var app = express(); | |
var server = require('http').createServer(app).listen(5000); | |
var bus = require('bus.io')(server); | |
bus.io().on('connection', function(socket) { | |
console.log(socket.id); | |
socket.emit('echo', 'HERE IS MY BUS'); | |
}); | |
app.get('/home', function(req, res){ | |
var file = fs.createReadStream('./index.html'); | |
file.pipe(res); | |
}); | |
//==================================== | |
///Client | |
<script type="text/javascript" src="/socket.io/socket.io.js"></script> | |
<script> | |
var client = io.connect(); | |
client.on('connect', function () { | |
// client.emit('echo', 'Hello, Bus.io!'); | |
}); | |
client.on('echo', function (who, what) { | |
//argumetns == ["HERE IS MY BUS"] | |
document.body.innerHTML += '<h1>'+what+'</h1>'; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment