some js code for event model and web sockets