         # New requests are sent directly.
         call = send
 
-      socket.addEventListener 'close', ->
-        call = enqueue
-        user = null
-        delay ?= 4 # Initial delay.
-
-        notify.error """
-The connection with XO-Server has been lost.
-
-Attempt to reconnect in #{delay} seconds.
-"""
-
-        # Tries to reconnect after a small (increasing) delay.
-        $timeout connect, delay * 1e3
-
-        # FIXME: Use Fibonacci progression instead of exponential.
-        delay *= 2
+      socket.addEventListener 'close', -> backOff.backOff()
 
       # When a message is received, we call the corresponding
       # deferred (if any).


    # Currently logged in user.
    user = null

    # Function used to send requests when the socket is opened.
    send = (method, params, deferred) ->


      # When the WebSocket opens, send any requests enqueued.
      socket.addEventListener 'open', ->
        backOff.reset()

        notify.info 'Connected to XO-Server'

        # If there is a token tries to sign in.
        if (token = $cookieStore.get 'token')
