-1

I develop a turn based game and want to put up to browser to test with real users. because it is a turn based game I don't need it to be real time. my idea is using old school chatroom method to set text to communicate between 2 players. after much testing and reading, I found this site provide a relative decent guideline and I tested it on my server. However there are 2 problems that I don't know how to do:

  1. How do I keep the communication between the 2 specific players? I imagine if this is chatroom, every time a player start a game, it is just like start a private chat room and only allow another player to join in. How can I do that? I need to understand the methodology to be able to work around the code.

  2. if ever any of the player offline, how can I ping the other online player?

sooon
  • 4,718
  • 8
  • 63
  • 116
  • I believe by your broad questions that you are just wondering where to start. I think you should first implement the tutorial and get it working (without worrying right now about "rooms") and then come back when you have more specific questions and code to share. Forget about implementing the game for now, because you need to get the live interactivity working first it seems. – degenerate Feb 16 '14 at 17:04

1 Answers1

0

Your question 1, seems to be a matter of validation. You should just validate that a game is on-going between user1 and user2. Assuming you have a game table, you just restrict access to the page. You should probably have a chat-game tablet as well, if you're keeping history.

Your question 2, you have a page that is constantly flushing and updating the chat, you have access to the user session\cookie. Seeing as this is a 2 player-game, when you send out information, you set a flag, of last-received per used, if it's between longer then a minute, between one user receiving, just update the response, so that the user gets that information as well.

When the user comes back, just grant him access to the page again, using gameid, or something of sorts.

Actually not that hard.

André Catita
  • 1,313
  • 16
  • 19