In my understanding, we have two logical entities:
Games: engage interactivity between two players in a private
Players: website visitors (anonymous)
I will start with the players, because it will be easier. The visitor lands on your site, and there is a need to (unambiguously) identify it. The simplest solution is a guide that can be used as a session parameter or as a session cookie (my suggestion). Guid is not a null type, so any Guid of 32 zeros will be our undefined Guid.
Having your GUID visitors, you need a collection of keys / values ββthat will connect to them.
Scenario 1: Each visitor can be a player in only one game at a time. The <player, game> dictionary can do the job, and visitors who are not players can be easily traced (game = undefined Guid)
Scenario 2: Each visitor can be a player for many games simultaneously. The Dictionary <player, List <game β is the solution, but game = undefinedGuid will become List.Count = 0
Now let's see what you can do with games. First of all, you can use the GUID to identify your games. This means that your game dictionary will be Dictionary <Guid, Guid> for scenario 1 or Dictionary <Guid, List <Guild β for scenario 2. Obviously, you need a collection of keys / values ββfor games, say, in the form of Dictionary <gameGuid, gameDetails >. GameDetails should be a class containing the necessary information that can determine interactivity between players. In other worlds, this class should include the role of each player (role 1: the one who asks or role 2: the one who guesses), and the messages that they exchange, as a collection of keys / values, where the key is the player. Guid and value string message.
To summarize, you will need two static dictionaries defined in your global.asax, one for players and one for games. You will also need a GameDetails class similar to this (basic concept):
class GameDatails { public Guid Role1 { get; set; } // holds the guid of the player who asks public Guid Role2 { get; set; } // holds the guid of the player who guesses public List<KeyValuePair<Guid, string>> Messages; // holds the player/message pairs public GameDetails(Guid role1, Guid role2) { this.Role1 = role1; this.Role2 = role2; this.Message = new List<KeyValuePair<Guid, string>>(); } }
Adding and removing players is easy as well as games (players are connected to games).
There are many other things that you can do (i.e., someone who realizes the completion of work, and you arbitrarily assign another player to continue, etc.).
More or less, it is also a way to make asp.net chat with private rooms. You may find it useful to find and test a good sample of a simple asp.net script chat, see the logic and implementation, and adapt them to the above. In addition, you can extend the chat script to support private rooms and have two applications instead of one.
Needless to say, asp.net is more than enough for your project. What you have to consider is that if you cannot control the reprocessing of the application pool, you will also need a persistence level, otherwise you may lose your dictionaries.
If you need more help, just let me know.