I was bored, so I decided to implement servers on Scratch. When you make a request, your username, the identifier (sort of like a URL), and a body that you send with your request (which may contain anything you'd like, for example, this might contain player positions in a multiplayer game) is added to UpcomingMessages. The server (a special copy of the project that's looking for stuff in UpcomingMessages) takes your username off of UpcomingMessages and stores it in a list. It then finds the first username on the list, and puts that on MessageTo. It then, based off of your username, its identifier, and the body that you sent, makes a message. (In the demo shown here, it just responds "Hello, [username]! Requests received so far: [number of requests that it has received] Identifier: [identifier] Body: [body]" but you could make a much more complex server if you wanted. The client (what you're running on your computer) then indicates to the server that it has received the message, and displays the message that it has received. Meanwhile, the server erases Message and MessageTo, and starts its cycle again.
Credits: I found the case-sensing algorithm on the Scratch Wiki (I may eventually transition to a variable-based algorithm, but this'll do until then). Besides that, I made everything. There's a comment on the stage with some notes on features that'll be implemented later/won't be implemented because I'll drop this project. NOTE: This project won't do anything out of the box. You'll have to go into the project and change imakegames205 to your username in the Server sprite, so that you can run a server. Alternatively, remix this project and do the aforementioned username switch. If this doesn't work, make sure that you're not a New Scratcher, and if you aren't, post a comment! I'd be happy to help. Current issues: while running multiple servers, only one server gets "priority" and can be accessed. The other server doesn't respond. I'm not sure why this happens. CHANGELOG: 2018-10-19: Servers and clients will now give up after 400-500 frames of waiting, to prevent someone from freezing a server by not responding. Added support for Diffie-Hellman-Merkle key exchange. By sending a request of the form χd[partial key]d the server generate its own key, remember the resulting final key, and send back another partial key. By sending a request of the form χr[something that the server won't pay attention to] you can make the server forget about all of your keys. This isn't integrated into the sample UI, but will be eventually. There currently no support for encryption/decryption using the resulting secret keys. Also, the key generation uses the largest modulo Scratch could support without resulting in rounding errors, but it's still not secure. Don't use this to transmit sensitive information (for many reasons, not just this). 2018-10-18: Added support for identifiers and request bodies. Updated example to reflect this. 2018-10-17: Shared after ~4 hours of work. Support for some silly protocol that I made up on the spot, and nothing more. Unencrypted traffic only, and a 97-character charset. Have fun!