简体   繁体   中英

How can you iterate between a letter string on the text field of a button in ASP.NET/C# enviroment?

I have 9 buttons set up as a tic tac toe game. It is web browser based so for the two players to play, they must connect to the browser URL, and enter a que for a game. When they're in the game, the first player is decided by who joined the session first. When he presses a button on his browser, it sends a Request/response to the other player's browser to have that button filled in as the 'X' he has played. The the second player will press one of the nine buttons and have his text field filled in as 'O'. Again, this will send request/response to the host which sends to the first player's browser to show up that player two has played. What I mean by response/request is the validity checking of one game played on two browsers.

My question is, how can iterate between X's and O's between the two players playing?

When you want to provide real time interaction between multiple users in a web scenario, you need to use either long polling / web sockets. If you are working with ASP.Net, you can use libraries like SignalR or XSockets.Net which abstracts out the long polling / web sockets functionality depending on the browser capabilities. You can look at examples in these sites to figure out how to make it work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM