Skip to content
← Back to Community
Coordinate your repls with WebSockets! 🖥↕️️🌐️
Profile icon
h
has Hacker Plan
Scoder12

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 key and val. The only current keys are asdf and 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!

Voters
Profile icon
Simple21
Profile icon
SLMJ
Profile icon
BaseProgrammer
Profile icon
Necrodragon41
Profile icon
rounak
Profile icon
PXY
Profile icon
ospreykite
Profile icon
katyadee
Profile icon
mm173946
Profile icon
abc3354
Comments
hotnewtop
Profile icon
cs641311

how would u do this with node js

Profile icon
Scoder12

@cs641311 well the server is already in node, you can rewrite the client in node to use something like https://www.npmjs.com/package/ws to connect to the guessing server and make the guesses.

Profile icon
CullenDAvello

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:
return True
elif 'Nope' in r.text:
return False

Profile icon
Scoder12

@CullenDAvello Thanks! That's just checking the responses from the guessing server lol