r/node • • Nov 10 '20

Real time synced counter built with Socket.io, NodeJS and Express! The counter will be integrated in a live-quizzing platform I'm currently working on, to control the current question.

484 Upvotes

57 comments sorted by

72

u/gorsesoup Nov 10 '20

You can stop the double tap zooming with a meta tag, but very good otherwise

17

u/UtopianCorps Nov 10 '20

Thanks a lot! Will add the tag! :)

79

u/InfiniTechGames Nov 10 '20

<meta name="viewport" content="width=device-width, user-scalable=no" />

MDN

16

u/gorsesoup Nov 10 '20

That's the one, couldn't remember it off my head!

0

u/[deleted] Nov 11 '20

[deleted]

1

u/gorsesoup Nov 11 '20

It used to, is there an alternative now?

I haven't developed for iOS for some years as we only support windows now (government contract)

1

u/Cyral Nov 11 '20

I think it can be done with touch-manipulation in CSS, I can’t remember the specifics though

8

u/universe_inside1 Nov 10 '20

One little meteor.js crying in the corner 😁. Nice work, btw

1

u/UtopianCorps Nov 11 '20

Thank you, but tbh I still don't get these meteor.js jokes xD

5

u/xehbit Nov 11 '20 edited Nov 11 '20

Sorry, couldn't resist messing around with your app, the counter is a bit high heheh :)

Also, it seems that you're request "what num" quite a lot! The awesome thing about WebSockets it that you can push the state to all connected WebSockets when the value changes without the client asking the current state over and over again (The good old polling XHR way).

EDIT: In my opinion socket.io is a bit heavy, i prefer to use ws :-)

1

u/UtopianCorps Nov 11 '20

"A bit high"?! πŸ˜‚πŸ˜‚ (Great hack btw xP )

Thanks a lot for the advice!

Since everyone in the comments has mentioned about sockets.io being heavy, I would love to try the websockets implementation now. =)

2

u/kevinzaki Nov 10 '20

Currently building something similar but for trivia games using same stack plus react on the front end.

Basic concept is a host screen displays the question with users answering the questions using their phones

1

u/UtopianCorps Nov 11 '20

Exactly the thing I'm trying to build...
Won't be using react though cause I think vanilla HTML, CSS would be enought
Or bootstrap at most

2

u/kevinzaki Nov 11 '20

React is not necessary but I am using this as a portfolio project and want to improve React skills. Good luck! I should be done in a few days then i'll post it up here.

1

u/UtopianCorps Nov 11 '20

Good luck! Would love to see your work!

0

u/[deleted] Nov 11 '20

[deleted]

1

u/kevinzaki Nov 11 '20

That's cool. I'm just building this as a side project with minimum functionality and trying to make it super easy to use. A lot of the functionality is complete. Still need to style it up. I'll post it up here and share the code when it is complete.

2

u/wise_introvert Nov 11 '20

Just out of curiosity, if this is a seperate application, how do you plan on integrating it in another application? Or is this is just a POC and you'll simply redoing it in the main application?

1

u/UtopianCorps Nov 11 '20

Yeah, POC is the right term, thanks!

2

u/Miridius Nov 11 '20

Feathersjs could be a good fit for your project, I'd suggest checking it out

2

u/UtopianCorps Nov 11 '20

Thanks a lot for the advice! Will check! :)

2

u/PiggiePlank Nov 11 '20

If you like real-time and sockets you should take a look at SocketCluster it's like socket.io ok steroids. It's awesome.

1

u/UtopianCorps Nov 11 '20

SocketCluster

Gracias! I will check! :)

2

u/alex_agc Nov 11 '20

Do you thing about the using of a mqtt server just after the websocket server?? that's perfect if you are thinking in doing a native app too.

1

u/UtopianCorps Nov 11 '20

That's nice! I recently started with backend so still learning this stuff!

2

u/dankobgd Nov 11 '20

why is this upvoted 500 times? what am i missing?

you update a number via websocket, and you are even using socket io which is not meant for this anyway compared to faster and pure websocket libraries like ws.

1

u/UtopianCorps Nov 11 '20

With all due respect I've just started learning back end and in case you want to give constructive feedback, you are welcome.

31

u/[deleted] Nov 10 '20

You should make voting machines for the US

10

u/BigGingerJake Nov 10 '20

And make both colours blue.

1

u/smith-huh Nov 11 '20

No ... red ("Aaaiiieeeeee....." - Bridge of Death, Monty Python et.al.)

-1

u/UniversalJS Nov 11 '20

To replicate the massive fraud that happened in the real election? :p

0

u/[deleted] Nov 11 '20

[deleted]

1

u/UtopianCorps Nov 11 '20

ikr xD

Thanks for all your comments! They are epic! πŸ˜†

3

u/BananaPrince69 Nov 10 '20

Very cool!

0

u/UtopianCorps Nov 10 '20

Thank you! =)

4

u/[deleted] Nov 10 '20

Socket.io is quite resource hungry. My experience of optimizing it wasn't good nd i don't prefer using it at all for big projects.

2

u/LinkifyBot Nov 10 '20

I found links in your comment that were not hyperlinked:

I did the honors for you.


delete | information | <3

1

u/applejak Nov 10 '20

What do you prefer?

4

u/johnyma22 Nov 11 '20

ws or uws.

op is right. if you are building anything serious, migrate away from socketio early.

2

u/[deleted] Nov 10 '20

Tbh i don't know myself. I prefer pusher if you need real-time factor for just a small part of your application.

2

u/Omkar_K45 Nov 11 '20

Thanks for the project Idea sir !

2

u/TheNicklesPickles Nov 11 '20

Slightly different stack, but I’m working on a multi-user quiz app too!

-2

u/raphaelarias Nov 10 '20

Like Meteorjs

0

u/[deleted] Nov 10 '20

[deleted]

11

u/rockefeller22 Nov 11 '20

My brain: Italy? No sideways. Hungary? No red is on top. Iran? Maybe.

2

u/UtopianCorps Nov 11 '20

πŸ˜‚πŸ˜‚

1

u/Knettwerk Dec 07 '20

πŸ€£πŸ€£πŸ€£πŸ˜‚πŸ˜‚πŸ˜‚

0

u/[deleted] Nov 10 '20

[deleted]

8

u/UtopianCorps Nov 10 '20

https://socket.io/get-started/chat/

I referred to this post from the official site. It's a great way to get started.

0

u/[deleted] Nov 11 '20

[deleted]

1

u/UtopianCorps Nov 11 '20

Recently started with node and backend, so it's more like project-based learning than an actual app. Anyways, it's also a POC for a live quizzing platform I'm currently working on.

5

u/[deleted] Nov 10 '20 edited Nov 10 '20

[removed] β€” view removed comment

14

u/cultulhul Nov 10 '20

Can you explain it here in the comments tjay more people can see

4

u/[deleted] Nov 10 '20

Please explain it here

3

u/[deleted] Nov 10 '20

Please give some explanation here ou link a blog post. :)

3

u/s_trader Nov 10 '20

I assume you're using redis's pub-sub for that right?

Probably you set the IDs in the fashion of putting the user ID then period then whatever notification / alert / update you want to push to the client (for example user_id.new_message_id) then when a user connects to socketIO you subscribe that server to the user's Pub using * (like that user_id.*) this way your server receives all the notification that user should receive and then you can tells socketIO to emit whatever data it needs to the proper clients even if there are multiple clients connecting to multiple different servers and are in the same chat room for example...