I'm building a chat app. Users can send messages, photos and videos.
My client-side code so far (simplified):
// for a text message
socket.emit('message', { from: 'john', to: 'jane', type: 'message', data: 'hi' })
// for an image
socket.binary(true).emit('message', { from: 'john', to: 'jane', type:'image', data:'...base64string...'})
This works, but I also want to be able to send (small) videos, and I'm guessing base64-encoding a video and sending it over a socket is not the best solution.
It's not for live videos, but pre-recorded videos.
The conversation is stored client side, not server side, the client has a redux state with an array of all messages.
What is the best solution to send/stream images and videos over websockets to other clients? Is there a library for this?
I'm using react-native client side and nodejs server side.