Functioning long polling implementation. Automatically falls back to it if websockets not defined. Very possible there are still some bugs though.