Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

chat and tic tac toe concept

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I've been thinking I want to try a web based Tic Tac Toe game with a small chat on the side.
Now I need some ideas for the concept of both.
For the Tic Tac Toe it'll be two player game and using Ajax for the user interface so that when a user clicks it sends a request to a Servlet to put a X or O picture on the web page based on the ID of the player and his permission to play (his turn). My idea of the board in the code so far is a two dimension array of classes representing X or Os.
My question is how is this 2D array going to be shared between 2 clients, so where shall I save this data I don't want to use a database or a file, and how when a user places X for example the other user's page is refreshed to show it ?? Also for the chat I'll be using Ajax but I have no idea where data will be saved also. Suggestions please I need to know best practices.
 
Sheriff
Posts: 67620
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose an appropriate forum for your posts. This forum is for questions on JSP. For more information, please click this link ⇒ CarefullyChooseOneForum.

This post has been moved to a more appropriate forum.
 
S Ali
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please take the time to choose an appropriate forum for your posts. This forum is for questions on JSP. For more information, please click this link ⇒ CarefullyChooseOneForum.

This post has been moved to a more appropriate forum.



Okay sorry, I thought it was related because I'm using JSP and Ajax.
 
Bear Bibeault
Sheriff
Posts: 67620
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can set a timer to periodically fire off an Ajax call to see if the game data has changed.

In order for the game data to be available for both sessions, it needs to be stored on the server. As it doesn't need to be permanent (except perhaps tracking high scores), you can just keep it in memory. For servlet-powered apps, the application context could be used.
 
reply
    Bookmark Topic Watch Topic
  • New Topic