xpaulbettsx/rdio-play-here — pull request #1 by xpaulbettsx (2013-05-30 07:03:05+00:00)
Title: Login data to background page

When our background page first starts up, it cannot simply connect immediately to the server via socket.io, because it doesn't know the Rdio user associated with this browser. To find this out, we have to jump through some hoops:

## How does this work?

1. We include a piece of Javascript in every Rdio tab that sets up a message receiver that will grab out the user from LocalStorage and return it in the message response
1. We set it up such that every time we open an Rdio tab, we update our saved user info in the background page's LocalStorage.
1. When the background page starts up, we see if we have Rdio user info already saved - if not, we loop through the running tabs looking for an Rdio tab. If we find one, we send it the "getUser" message, if not, we create a new Rdio tab (TODO: This is a bit jarring for the user :-/)