dongshou9343 2011-07-22 17:04
浏览 64
已采纳

即时挑战/通知系统

My setup: Currently running a dedicated server with an Apache, PHP, MYSQL. My DB is all set up and stores everything correctly. I'm just trying to figure out how to best display things live in an efficient way.

This would be a live challenging system for a web based game.

  • User A sends a challenge to User B

  • User B is alerted immediately and must take action on whether to Accept or Decline

  • Once User B accepts he and User A are both taken to a specific page that is served up by the DB (nothing special happens on this page,and they dont need to be in sync or anything)

The response from User B is a simple yes or no, no other parameters are set by User B, the page they are going to has already been defined when User A sends the challenge.

Whichever config I implement for this challenge system, I am assuming it will also work for instant sitewide notifications. The only difference is that notifications do not require an instant response from User B.

I have read up on long polling techniques, comet etc.. But im still looking for opinions on the best way to achieve this, and make it scalable.

I am open to trying anything as long as it will work with (or in tandem) to my current PHP and MYSQL set up. Thanks!

  • 写回答

1条回答 默认 最新

  • doubleyou1001 2011-07-23 02:18
    关注

    You're asking about Notifications from a Server to a Client. This can be implemented either by having the Client poll frequently for changes, or having the Server hold open access to the Client, and pushing changes. Both have their advantages and disadvantages.

    EDIT: More Information

    • Pull Method Advantages:
      • Easy to implement
      • Server can be pretty naïve about who's getting data
    • Pull Method Disadvantages:
      • Resource intensive on the client side, regardless of polling frequency
      • Time vs. Resource debacle: More frequent polls mean more resource utilization. Less resource utilization means less immediate data.
    • Push Method Advantages:
      • Server has more control overall
      • Data is immediately sent to the client
    • Push Method Disadvantages:
      • Potentially very resource intensive on the server side
      • You need to implement some way for the server to know how to reach each individual client (for example, Apple uses Device UUIDs for their APNS)

    What Wikipedia has to say (some really good stuff, actually): Pull, Push. If you are leaning toward a Push model, you might want to consider setting up your app as a Pushlet

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路