31-12-2011, 04:26 AM
"The 'data' event emits either a Buffer (by default) or a string if setEncoding() was used." Oups :-°
Correction :
Correction :
// Serveur
var html = require('fs').readFileSync(__dirname+'/app.html');
var http = require('http');
var app = http.createServer(function(req, res){ res.end(html); });
app.listen(8080);
var io = require("socket.io");
var io = io.listen(app);
io.sockets.on('connection', function (socket) {
var options = {
host: 'localhost',
port: 80,
path: '/FUCORE/php/evenement.php',
method: 'GET'
};
var req = http.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function (contents) {
socket.emit('divContents', contents);
});
});
req.end();
});