logout code put in onbeforeload of window so that clicking window close
will also result in logout. redirect from inside the chatbox will
also trigger logout (means hitting ctrl+r will also trigger logout.
safer this way)
Refactor codes. Grouped related controller methods. Used string userName
as parameter used in the services (instead of user object, user object
is just fetched inside the service if user object is really needed).
Client side of file attach materialized in this commit.