Coordinate your repls with WebSockets! 🖥↕️️🌐️
Use the power of multiple repls to solve tasks quickly!
Before we start, make sure to 🔼 smash that upvote button! 🔼
How can coordination help?
Well, it can help in a lot of different ways but usually on a task that is doind something repetitively. Coordination between repls can make this faster because the more repls work on that task at the same time, the faster it goes!
Heres an example.
I made a simple web server to this in action: https://repl.it/@Scoder12/guess-it
Its really simple. You send a GET request to the
/guess endpoint with the params
val. The only current keys are
hjkl. It will respond with
You got it! or
Nope! Try again.... depending on whether the data matches. Also, as more of a challenge, the server delays responses by 300 ms to simulate some kind of database query and to stop spam.
How would we use coordination to guess this?
There is a server to sync the clients https://repl.it/@Scoder12/Guesser-Cluster and client to connect to the server and do the work https://repl.it/@Scoder12/guesser. If you want to see a tutorial on how to coordinate everything, hit upvote 🔼 and leave a comment for me!
Hit fork on each of those repls and change the
ws_url variable in the client and copy your server address. Make sure to change https:// to ws:// or it won't work!
Thanks for reading! Upvote if you enjoyed! Comment any questions/issues/suggestions!
Note: The repl below \/ \/ will not work if the server is not running!
this is a great concept and im happy to report it worked wonderfully, btw couldn't help looking through the code and i love the names of things in this language emphasis on nope
if 'got it' in r.text:
elif 'Nope' in r.text: