I'm new to installing faye
I'm using some JavaScript
but I can't understand how this is actually working. Can anybody explain please ? here is JavaScript
that I'm using :
window.client = new Faye.Client('/faye');
client.addExtension({
outgoing: function(message, callback) {
message.ext = message.ext || {};
message.ext.csrfToken = $('meta[name=csrf-token]').attr('content');
return callback(message);
}
});
jQuery(function() {
var chat_room, error;
chat_room = $('#chat-room-id').val();
try {
client.unsubscribe('/events/'+chat_room+'/ideas');
} catch (error) {
if (typeof console !== "undefined" && console !== null) {
console.log("Can't unsubscribe.");
}
}
return client.subscribe('/events/'+chat_room+'/ideas', function(payload) {
alert(payload)
if (payload.message) {
return $('#comments').find('.media-list').prepend(payload.message);
}
});
});
Aucun commentaire:
Enregistrer un commentaire