#how can i update data in real time

29 messages · Page 1 of 1 (latest)

fervent talon
#

i am working on a gartic phone esque, multiplayer game but i am stuck thinking about one thing, how would i create a joinable lobby

like say you need a specific code to join an existing lobby but how could i achieve that using javascript if it even is possible, otherwise please educate me about other ways to achieve similar goal

i am expecting the lobby to be updated and the game working as intended when someone joins a lobby in real time

any help is much appreciated 🎀 💝

earnest peak
#

You're using JavaScript in the backend?

fervent talon
#

this will sound really dumb of me but i wasnt planning on using any backend 😭

spiral geyser
#

PHP is very easy to learn. Maybe you'd like to learn python as a general-purpose tool. Or just wanna use JS through Node.js

#

You unfortunately need a backend for this

fervent talon
#

i know the basics of PHP but i am not sure how will that work for me

spiral geyser
#

(You'll quickly learn that writing backen code is a lot better than front-end :P)

fervent talon
#

i mean like fetching data from database and stuff

spiral geyser
#

did you learn OOP?

#

oh

fervent talon
#

i learnt procedural :(

spiral geyser
#

i think thats enough. I think you could get around OOP through stackoverflow and online code help. Post here if you need more help

fervent talon
#

okayy

#

but i am still not sure about one thing

#

i am not sure how that will update data in real time

like i have 2 browsers, i create a lobby from browser 1 and join with 2, how will i achieve this?

spiral geyser
#

as for "updating data in real-time", you use AJAX or fetch API

fervent talon
#

ah okay

#

i tried to find solution from chatgpt and it suggested me to keep it all front end and use something web sockets, socket.io for updation

spiral geyser
#

ok. This is more of a DB thing: you create a "players" table and a "games" table

spiral geyser
fervent talon
#

😭 its a completely new thing for me

spiral geyser
#

but im not sure how it wants you to use web sockets without a backend

fervent talon
#

yeah it just told me to use it for updation

#
  • use express js
spiral geyser
#

i cant help with JS frameworks, sorry

fervent talon
#

okay i will try with PHP for backend

earnest peak
#

Don't think that makes sense tbf

#

You'll need some sort of server, just Express would probably be enough (or maybe one shipped with whatever frontend framework if you're using that)