doujiao4705 2014-11-22 16:23
浏览 19
已采纳

如何在AJAX XML的同时重定向两个用户?

I have two logged in users, with "id" and "id2". Both users are on index page, but there are also other users.

If one of the users click the button, he and the other user (with id2) to be redirected to another page. How am I supposed to redirect only these two users at the same time.

function redirect() {
     //redirect only user with id and id2
}
  • 写回答

2条回答 默认 最新

  • doufan2541 2014-11-22 16:37
    关注

    This depends on how complicated you plan on making your game. Generally for online games, the state is stored on the server, and the clients are just viewers with varying levels of smartness.

    Assuming you have somethink like a 'find game' button, the users would send a request to the server and the server would redirect to the 'room' URL for a game that needs more people, or a new room would be created so other people could join this user.

    Once people start joining the room, they would need to basically wait for the room owner to start the same. There are a bunch of ways to do this. In your case, the simplest is to have each client keep sending requests to the server to see if the game has started or not, and if so, redirect to the new URL. The clients could also use websockets or long polling to accomplish this if you wanted potentially better reaction times.

    So basically, you aren't "redirecting two users at the same time", you are changing the state of the game from "waiting for people" to "started" or something like that, and then when each user seems that the game is started, then server would redirect them.

    Basically, I'd think of the game as two people talking to a server separately. The fact that they are playing the same game is reflected in the state of the game, but they aren't usually communicating directly with each other.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码