Closed guidobouman closed 3 years ago
If you can point me in the right direction and allow me to pick your brain a little, I think I should be able to write the PR within the next couple of days.
Good question – it's intentional that the cocoding session is cleared for a few reasons (mainly speaking of online hosted version):
security (I don't log any of the code, just sync it while session is active, and i think 15min after last person leaves room, i purge it), otherwise, you might appear in a room coincidently with code already there (infinite loop bug bomb??)
optomization, i don't want to have to maintain/keep/log those sessions (in DB or otherwise).. which partially had to do with using glitch.com as initial host server (i think had max run life of 4 hours when in use) – I've since upgraded, but mainly first reason stands.
I see cocoding as a volatile space for jamming/collab. The 'clone sketch' function of cocoding is intended for exactly that archiving of anything you do collaboratively on your local machine. Good to regularly clone the sketch as progress takes place. I had an 'import to session' function for cocoding - where the inititor (or guest with permission) could replace the shared code with a local sketch (especially useful for teaching) – but it ended up having major syncing issues when changing the whole code with 25 students at once (since all delta changes are single keystroke syncs!) – i wanted to find a way to pause the syncing of peeredit rga – then via websockets replace editor contents of everyone – then re-activate the syncing of code (essentially starting over its history), but still haven't found a way. (awesome if you have insight/ideas for that). When that would work – would be really easy to land in a cocoding session and just load your local sketch to the session (like what you describe above). I have that whole funcitonality written in another branch that got put on a pause until solving the rga syncing pause/init issue.
Also closing this, as it's addressed above – I want to purge the COCODING sessions, so you don't get put into a room that already has code (potentially malicious) – nevertheless, I updated the code and it now waits 24hrs after the last person left the room to purge everything. I found a bug that was crashing the server every once in a while when trying to track the cursor position of someone who had exited... so now it's been running 25days without an issue = should be far more stable. I think it's best to simply clone your COCODING session to sketches folder and when wanting to reboot things – just paste it in when firing up again. Same for SyncData – you can save whatevers in that editor as a template to pull up again (also overwriting a preset if only updating vars). Lastly, I implemented an 'autoclone' feature incase the websocket server is ever lost (can happen if I have to reset/upgrade the COCODING server) – so hopefully nothing gets lost in this volatile space.
When the server restarts, each cocoding session is empty after a page refresh. When the session is empty, the cocoding session can potentially offer to restore the session from a local cache copy.
What do you think?