 # Loads the connection data from local storage.
 restoreData = ->
   if sessionStorage?
-    for k in [ "jid", "sid", "rid", "host", "port", "path" ]
+    for k in [ "jid", "sid", "rid", "host", "port", "path", "protocol" ]
       j = key2cache k
       connection_options[k] = sessionStorage[j]  if sessionStorage[j]
 

create_connection_obj = ->

  new Strophe.Connection get_bosh_url
    path: connection_options.path
    host: connection_options.host
    port: connection_options.port

key2cache   = (k) -> "#{CACHE_PREFIX}#{k}"



mediator = new scaleApp.Mediator

ID               = "xmpp"
DEFAULT_PATH     = "http-bind/"
DEFAULT_PROTOCOL = "http"
DEFAULT_PORT     = 5280
CACHE_PREFIX     = "scaleApp.#{ID}.cache."

# Variable that holds the Strophe connection object
connection = null

# Object that holds all connection sepecific options.
connection_options =
  host:     document.domain
  port:     DEFAULT_PORT
  path:     DEFAULT_PATH
  protocol: DEFAULT_PROTOCOL
  jid:      null
  sid:      null
  rid:      null

# Generates an appropriate bosh url for the connection.
#
