refactor websocket to support by id or by connection, also add lock