moved sendToGateway under $rootScope
automatic reconnection from the browser when losing a websocket connection