Correctly switching between polling/websockets