Trying to make a messenger like google hangouts

I am trying to make an application that has a messenging system like Google Hangouts. I am using the mailboxer gem. I am lost on how to use unobtrusive javascript for this because the messenger will be available on every page of the application as long as the user is logged in.