Object oriented chat client in javascript