Add websocket support

Use websockets by default if supported by browser, otherwise use polling method