简体   繁体   English

在ASP.NET/C#环境中,如何在按钮的文本字段上的字母字符串之间进行迭代?

[英]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. 我有9个按钮设置为井字游戏。 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. 它是基于Web浏览器的,因此要让两个玩家玩,他们必须连接到浏览器URL,并输入游戏的que。 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. 当他按下浏览器上的按钮时,它将向其他播放器的浏览器发送请求/响应,以将该按钮填充为他所播放的“ X”。 The the second player will press one of the nine buttons and have his text field filled in as 'O'. 第二名玩家将按下九个按钮之一,并将其​​文本字段填写为“ 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? 我的问题是,两个玩家之间如何在X和O之间进行迭代?

When you want to provide real time interaction between multiple users in a web scenario, you need to use either long polling / web sockets. 如果要在Web场景中提供多个用户之间的实时交互,则需要使用长轮询/ Web套接字。 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. 如果使用的是ASP.Net,则可以使用SignalRXSockets.Net之类的库,这些库会根据浏览器功能抽象出长轮询/ Web套接字功能。 You can look at examples in these sites to figure out how to make it work. 您可以在这些站点中查看示例,以了解如何使其工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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