 
     # Identifier of the next request.
     nextId = 0
+
+    # Delay in seconds from the next reconnection attempt.
+    delay = 2
 
     # Promises linked to the requests.
     deferreds = {}


      # When the WebSocket closes, requests are no longer sent directly
      # but enqueued.
      socket.addEventListener 'close', ->
        call = enqueue

      # When a message is received, we call the corresponding
      # deferred (if any).

    }

  # This service provides an access to the Xen-Orchestra API.
  .service 'xoApi', ($location, $q, $timeout, notify) ->
    url = do ->
      # Note: The path is ignored, the WebSocket must be relative to
      # root.
