Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 检查推进器中的所有通道是否触发事件_Javascript_Php_Timer_Pusher - Fatal编程技术网

Javascript 检查推进器中的所有通道是否触发事件

Javascript 检查推进器中的所有通道是否触发事件,javascript,php,timer,pusher,Javascript,Php,Timer,Pusher,我正在建设一个使用Php和实时招标网站。网站上有一个倒计时装置 如果计时器低于15秒,并且有人出价竞拍,计时器将再次重置为15秒。我正在使用Pusher更新所有打开浏览器中的计时器。当计时器达到0时,将调用一个函数来结束拍卖 以下是我面临的问题: 如果有人在计时器还剩1秒左右时出价,则会在出价发生的浏览器中更新计时器。但由于Pusher需要大约一秒钟来更新其他浏览器,计时器在其他计算机上结束,结束拍卖的函数被调用 以下是我目前正在做的工作的示例代码: var pusher = new P

我正在建设一个使用Php和实时招标网站。网站上有一个倒计时装置

如果计时器低于15秒,并且有人出价竞拍,计时器将再次重置为15秒。我正在使用Pusher更新所有打开浏览器中的计时器。当计时器达到0时,将调用一个函数来结束拍卖

以下是我面临的问题:

如果有人在计时器还剩1秒左右时出价,则会在出价发生的浏览器中更新计时器。但由于Pusher需要大约一秒钟来更新其他浏览器,计时器在其他计算机上结束,结束拍卖的函数被调用

以下是我目前正在做的工作的示例代码:

    var pusher = new Pusher('key');

    channel = pusher.subscribe('wppa');

    pusher.connection.bind('connected', function(){

    });

    channel.bind('bid_added_event', function(response) {
        StreamedAuction.update(response, AuctionModel); 
    });

    channel.bind('end_auction_event', function(response) {
        StreamedAuction.end(response, AuctionModel);
    });

    channel.bind('update_timer_event', function(response){
        StreamedAuction.updateEndDate(response, AuctionModel);
    });
如果有人出价且计时器小于15,则调用更新计时器事件来更新所有通道中的计时器

如果计时器达到0,则调用
结束拍卖\u事件
。问题是,如果有人在计时器为1秒时出价,拍卖甚至在调用
update\u timer\u事件之前就结束了

我想知道在pusher中是否有一种方法可以让你听到事件是否在所有通道中被触发。如果这是可能的话,我想我可以做如下事情:

if the event is fired in all browsers
   then end the auction
else
   reset the counter to 15 in all channels
   as somebody bided and the auction ending event wasnt fired from
   one of the channel
如果您需要更多详细信息或代码,请告诉我


谢谢。

这是另一个问题的副本,我建议您关闭另一个,因为这一个提供了更多信息。我已投票关闭其他问题。