I
I
Ivan Ivanov2019-07-29 20:21:55
JavaScript
Ivan Ivanov, 2019-07-29 20:21:55

Subscription not working in Ratchet?

I use Ratchet. The user connects, that is, onOpen works, but nothing happens when the subscription user connects. I do according to the documentation: socketo.me/docs/push
Here is the code:

var conn = new ab.connect('ws://localhost:8080',
                function(session) {
                    session.subscribe('kittensCategory', function(topic, data) {
                        // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
                        alert(101111);
                        console.log('New article published to category "' + topic + '" : ' + data.title);
                    });
                },
                function() {
                    console.warn('WebSocket connection closed');
                },
                {
                    'maxRetries': 60,
                    'retryDelay': 4000,
                    'skipSubprotocolCheck': true
                }
            );

This code does not work (even the alert is not displayed):
function(session) {
                    session.subscribe('kittensCategory', function(topic, data) {
                        // This is where you would add the new article to the DOM (beyond the scope of this tutorial)
                        alert(101111);
                        console.log('New article published to category "' + topic + '" : ' + data.title);
                    });
                },

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question