I am trying to use Faye to create a simple chat room with Rails and place it on the hero. So far, I have managed to start the Faye server and make it work with instant messages. The key lines of code that I use are:
Javascript file launched on page load:
$(function() { var faye = new Faye.Client(<< My Feye server on Heoku here >>); faye.subscribe("/messages/new", function(data) { eval(data); }); });
create.js.erb that starts when the user sends a message
<% broadcast "/messages/new" do %> $("#chat").append("<%= j render(@message) %>"); <% end %>
Everything is working fine, but now I would like to let you know when the user disconnects from the chat. How can I do it?
I already looked at the Faye website for monitoring , but it is not clear where I should put this code.
source share