banool / codenames-pictures

Play Codenames Pictures using a TV or computer for the board
https://codenames-pictures.dport.me
22 stars 18 forks source link

Accept user images #4

Closed banool closed 6 years ago

banool commented 6 years ago

It'd be cool if the user could specify their own images via the front end. It'd be too expensive (and insecure) for my server to have them uploaded there. Instead it'd be good if the user could:

banool commented 6 years ago

I've taken a crack at this and it's proving difficult. Passing the link in via the URL is not working well, I would have to do some escaping and unescaping. The ideal flow is:

With s.imagePaths changed. the game should use the user's images.

The problem with using s.imagePaths is that this is global to the server, so this would fuck things up if multiple games are being played at once. You could maybe change it back to what it was before when you hit handleRetrieveGame if the user-supplied image link is empty. There could be races here. Ideally the images used would map to a single game, not the server, but that would be a painful refactor.

Maybe you could put the escaped link in the URL and leave it there. That'd make the images local to the game. I'm not sure if that works though to maintain state properly between players, though it should since everyone is using a link with the image source baked into it. You'd still have to attach it to the game object and not s.imagePaths though.

banool commented 6 years ago

As of #15 this is done!