Jump to content
  • Advertisement
Sign in to follow this  
pintee

Consistency across sessions

This topic is 1877 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone,

 

I am making a text based browser rpg and I've stumbled into a bit of a problem and am not sure how to proceed. How do you keep consistency across multiple instances of the game running at the same time?? For example....

 

Say a user is playing the game in one window. He/She is presented with the hyperlink "Open Blue Door" which will load a new screen of the game. Say the user opens that link in a new window. There will now be two instances of the game running, and it would be possible to play the game along one storyline in one window and play the game along another completely seperate storyline in the other window. In other words, there would be two instances of the game running at the same time and they would be inconsistent.

 

Or another example is if a user is in the middle of a game, opens a new window, goes to the website and hits play, it should go directly to where the user is in the other window and not start a new game.

 

I apologise if this is a noob question and thank you for your time in advance.

Share this post


Link to post
Share on other sites
Advertisement

You can maintain an "action counter" on the client and the server. Every time the user makes an action, the client submits the current value along with their command. The server will not process commands if the client's action counter is out of date, you might instead redirect the user to their current location in the most recent game (in your example, this would be behind the blue door)  with an up to date "action counter" value. If the server and client action counter values match, the server increments this value, performs whatever logic it needs to and then renders the next page for the client, which will include the current action counter.

Share this post


Link to post
Share on other sites

Hi rip-off thanks for the reply. I think I understand what you're getting at, but how might i maintain an action counter on the client and server? Would the client be writing to cookies and the server involve writing to database? Sorry again for the noob questions, I'm new to web development and i don't quite yet grasp how it all fits together.

Share this post


Link to post
Share on other sites

Also, if i'm understanding you correctly does this imply that if there are several instances of the game open at the same time, there are several respective client variables being maintained?

Share this post


Link to post
Share on other sites
Not sure what your question is but if it's about maintaining state between server requests then you should look into php sessions. Basically the server can save some data that you access through a $SESSION array and the client sends a cookie with an id that retrieves the right session data across http requests. That's how a browser does it but you could emulate cookies by embedding the data in http headers (which is how cookies work under the hood anyway)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!