refactor websocket 2 pubsub flow