Long-polling implementation.