Better API for websocket