 
 ; --------------------------------------------
 
-; TODO: Split between logical schema and physical runtime objects.
-
 (defn coll-handler [actx coll-state m]
   [coll-state nil])
 

    {:rev rev
     :name name
     :coll-ch coll-ch}))

(defn make-initial-server-state [actx]
  (let [c (make-coll actx 0 "default")]

  {:cur-realm "_lobby"
   :cur-realm-collset "default"
   :cur-realm-collset-coll "default"
   :cur-coll nil ; Either nil or result of make-coll.
   :cur-user-realm "_lobby"
   :cur-user "_anon"})

(defn lane-state-loop [actx server-state-ch]
  (let [req-ch (achan actx)]
    (act lane-state-loop-init actx
         (let [ils initial-lane-state
               res (areq lane-state-loop-init server-state-ch
                         {:op :authenticate
                          :user-realm (:cur-user-realm ils)
                          :user (:cur-user ils)
                          :pswd ""
                          :realm (:cur-realm ils)
                          :realm-collset (:cur-realm-collset ils)
                          :realm-collset-coll (:cur-realm-collset-coll ils)})]
           (state-loop actx :lane-state lane-handler
                       (assoc initial-lane-state :cur-coll (:coll res))
                       :req-ch req-ch)))
    req-ch))

