websocket.js rewritten as class