Better api for websocket