Slide 22
Slide 22 text
࣮ݱํ๏
// client side
var img = canvas.toDataURL('image/webp');
var binary = window.atob(img.split(‘,')[1]);
// binaryΛͦͷ·· emit
socket.emit(‘image’, binary);
!
// server side
io.on('connection', function(socket){
// ࠓ·ͰͱมΘΒͳ͍ɺimage ΠϕϯτΛड͚औΔ
socket.on('image', function(data){
// ड͚औͬͨbinaryͷσʔλΛbroadcast͢Δ
socket.broadcast.volatile.emit('image', {
id: socket.id,
blob: data
});
});
});