pusher有时只订阅活动

时间:2011-10-17 06:23:38

标签: javascript websocket

为什么推动器随机工作,有时它可以接受推动,有时它不是......

仅在调试器显示订阅

时才有效
Connection  1614.1447055    Origin: http://127.0.0.1:3000   06:23:34
Subscribed  1614.1447055    Channel: export 06:23:34

但是当调试器显示

Connection  1624.1445840    Origin: http://127.0.0.1:3000

但没有订阅,它不起作用。 为什么?它是相同的JavaScript。

订阅真的很长,为什么?

<head>
    <title>Share Your Application</title>
<script src="http://js.pusherapp.com/1.9/pusher.min.js" type="text/javascript"></script>
<script type="text/javascript">


    // Enable pusher logging - don't include this in production
    Pusher.log = function(message) {
      if (window.console && window.console.log) window.console.log(message);
    };
    // Flash fallback logging - don't include this in production
    WEB_SOCKET_DEBUG = true;

    var pusher = new Pusher('ba6867c72bd360e49f8c');


    var channel = pusher.subscribe('export');

    channel.bind("project-2.html", function(d) {
        alertBox_Show("Export successful!","Thank you for exporting the site. Please check your download folder.");
        window.location = d.link;
        sessionStorage["is_export"] = true;
        unlockScreen(); 
        $("#ajax_loading_image").hide();
        $( "#republish_confirmation" ).dialog( "close" );
    });

    channel.bind("project-2.iads", function(d) {
        alertBox_Show("Export successful!","Thank you for exporting the site. Please check your download folder.");
        window.location = d.link;
        sessionStorage["is_export"] = true;
        unlockScreen(); 
        $("#ajax_loading_image").hide();
        $( "#republish_confirmation" ).dialog( "close" );
    });

    channel.bind("my_event", function(d) {
        alert(d);
    });

</script>

</head>

1 个答案:

答案 0 :(得分:0)

好的......我找到了原因。 pusher.connection.state;正在连接。在chrome linux中连接需要很长时间....