I'm not a programmer... I can create a websocket aplication in node.js, that can send an image to borwser, but I will have few images, that changed sometimes. Ex. image1.jpg image2.jpg image3.jpg image4.jpg and I need to keep updated this images in browser.
My app now work only with one image, without update. The full project is hear: https://github.com/akoscomp/imgstream I publish the image with this code:
io.sockets.on('connection', function(socket){
fs.readFile(__dirname + '/image.jpg', function(err, buf){
//it's impossible to ebed binary data
socket.emit('image', { image: true, buffer: buf.toString('base64') });
console.log('image file is initialized: ' + __dirname + '/image.jpg');
});});
And I can check the file update, but I can't automate the update on browser:
var watch = require('node-watch');
watch('image.jpg', function(evt, filename) {
console.log(filename, ' changed.');
});
Please help me to automate the image update in borwser. After that I probably can apply the code for many images.
via Akos
No comments:
Post a Comment