I just like to broadcast an image from server to client.
I can upload the image at one end of the client. But its not reflecting on the other side. What snippet I have to include to make these things work?
I think you should not use Socket.IO for high payload streaming (like pictures).
Try this:
In your server:
var socket = require('socket.io'),
io = socket.listen(yourApp);
io.sockets.on('connection', function(client) {
client.on('imageUploaded', function(imgURL) {
client.broadcast.emit('imageBroadcast', imgURL);
});
});
In your client:
var server = io.connect(yourServerIp);
// You image upload logic here. You can get the URL after uploading and then you call this function:
function imageUploaded(url){
server.emit('imageUploaded', url);
}
server.on('imageBroadcast', function(imgURL){
// Here you decide what to do with the image
});