0

双方向のクライアント/サーバー通信に Ratchet WebSockets と Autobahn.js を使用しています。すべてをインストールし、ポートを開きましたが、数週間 (はい、文字通り数週間) が経過しましたが、まだ機能しません。Autobahn の subscribe メソッドが正しく機能していないことに絞り込んだと思います。

私が使用しているのは、ここにあるサンプルコードをわずかに変更したものです。

http://socketo.me/docs/push

ここに私のクライアントコードがあります:

<script>
    window.define = function(factory) {
        try{ delete window.define; } catch(e){ window.define = void 0; } // IE
        window.when = factory();
    };
    window.define.amd = {};
</script>
<script src="/apps/scripts/when.js"></script> 
<script src="http://autobahn.s3.amazonaws.com/js/autobahn.min.js"></script>
<script>
    var conn = new ab.Session(
        'ws://light-speed-games.com:8080' // The host (our Ratchet WebSocket server) to connect to
      , function() {            // Once the connection has been established
            console.log('Connection established.');
            conn.subscribe('kittensCategory', function(topic, data) {
                // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
                console.log('New article published to category "' + topic + '" : ' + data.title);
            });
        }
      , function() {            // When the connection is closed
            console.warn('WebSocket connection closed');
        }
      , {                       // Additional parameters, we're ignoring the WAMP sub-protocol for older browsers
            'skipSubprotocolCheck': true
        }
    );
</script>

問題はここにあると思います:

function() {            // Once the connection has been established
                console.log('Connection established.');
                conn.subscribe('kittensCategory', function(topic, data) {
                    // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
                    console.log('New article published to category "' + topic + '" : ' + data.title);
                });
            }

この行console.log('Connection established.');はその役割を果たします - そのメッセージをコンソールに記録します。ただし、conn.subscribeメソッドは何もしません。kittensCategory他の文字列に変更しても問題ありません。それでも何もしません。しかしkittensCategory、ここで意味をなすのはそれだけです (上記のリンクから Ratchet のサンプル コードを参照してください)。

何か案は?

編集:

これは、ab.debug の出力です。

WAMP Connect autobahn.min.js:69
ws://light-speed-games.com:8080 autobahn.min.js:69
wamp autobahn.min.js:69
WS Receive autobahn.min.js:64
ws://light-speed-games.com:8080  [null] autobahn.min.js:64
1 autobahn.min.js:64
[0,"52cbe9d97fda2",1,"Ratchet\/0.3"] autobahn.min.js:64
WAMP Welcome autobahn.min.js:67
ws://light-speed-games.com:8080  [52cbe9d97fda2] autobahn.min.js:67
1 autobahn.min.js:67
Ratchet/0.3 autobahn.min.js:67
Connection established. client.php:15
WAMP Subscribe autobahn.min.js:74
ws://light-speed-games.com:8080  [52cbe9d97fda2] autobahn.min.js:74
kittensCategory autobahn.min.js:74
function (topic, data) {
                // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
                console.log('New article published to category "' + topic + '" : ' + data.title);
            } autobahn.min.js:74
WS Send autobahn.min.js:72
ws://light-speed-games.com:8080  [52cbe9d97fda2] autobahn.min.js:72
1 autobahn.min.js:72
[5,"kittensCategory"] 
4

0 に答える 0