Question

I'm quite new to working with Faye and I have a small question concerning it. I'm trying to call a redirect function to another page after I publish a string with Faye.

The problem is: the redirect mostly happens before Faye has gotten the chance to make it's connections and send it to the channel.

My question is: is there a way to check when Faye has succesfully published something and execute a function afterwards?

Thanks!

Was it helpful?

Solution

There is a way to check if publishing a message has been successful or not:

var publication = client.publish('/foo', {text: 'Hi there'});

publication.then(function() {
  // OK
}, function(error) {
  // NOT OK, redirect
});

This one is documented.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top