link sharing - 05 Mar 2022
Levels can now be shared with links. The purpose is to make it easy to share the levels you create with friends. Using link sharing is quite simple:
First click the link icon to the right of the screen.
Then simply click “get link” followed by “copy link” to copy the link to your clipboard. You can now paste it wherever you want.
Note that this link expires within 24 hours, so make sure your friend opens it before then. Fortunately, once it is opened the link expands to its full size. This larger link will not expire. However, these can get quite long so it is a bit cumbersome to pass these expanded links around.
If you’re interested why this is, I can briefly explain how link sharing works on the technical side. When you request a link by pressing “get link”, the game saves your level, similar to when you press the regular save icon. Once the game has collected this save data, it encodes it to a base 64 string. Base 64 is a way of storing binary data as characters. This means that they can be passed along into your browsers address bar. This base 64 string can be used to construct a url with the level data as a parameter, which looks something like this: “https://duck.place/?d=AQAAAA…..”. However, since this url has to be long enough to store the entire level it can be unpractical to share this link directly.
To solve this, the game takes this long link and sends it to a server which gives it a short name, which might look like “https://share.duck.place/abcdefg”. This server then remembers that whenever someone asks for this short link, they really want the long, expanded url that contains the entire level. Since the server must remember all expanded links, it consumes memory. There is a limit on 24 hours, as well as an upper bound on the total amount of links, to prevent it from taking up too much memory. If these limits become an issue I will expand them.
An interesting issue is that browsers have a limit for how large a url can be, effectively putting a limit on how large your level can be before it can no longer be shared. It depends on what browser you have. There is also a size limit on the server side. How big your levels can be I cannot say at the moment. It depends on the current level encoding scheme I have. This is unfortunate, as the player should really be given heads up if their level is about to grow to large. Giving players feedback on their level size so they know if it can be saved as a link or not is part of my backlog. So it will eventually be added.
That’s all for now. Hope you get some fun out of link sharing!
PS: I really need to organize the devlog better. There should both be a pages and an overview, so that it is easier to browse.