             [cbfg.world.base]
             [cbfg.world.net]))
 
-(defn state-loop [actx name loop-fn initial-state]
-  (let [req-ch (achan actx)]
+(defn state-loop [actx name loop-fn initial-state & {:keys [req-ch]}]
+  (let [req-ch (or req-ch (achan actx))]
     (act-loop state-loop actx [name name state initial-state]
               (when-let [m (atake state-loop req-ch)]
                 (when-let [[state-next res] (loop-fn state-loop state m)]

                        :users {"_anon" {:rev 0 :pswd ""}}
                        :collsets {"default" {:rev 0
                                              :colls {"default" c}}}}}}))

(def initial-lane-state
  {:cur-realm "_lobby"
   :cur-realm-collset "default"
   :cur-realm-collset-coll "default"
   :cur-user-realm "_lobby"
   :cur-user "_anon"}) ; TODO: Need cur-coll, too.

; --------------------------------------------


        [server-state (assoc m :status :invalid :status-info :bad-key)])
      [server-state (assoc m :status :invalid :status-info :auth)])

    :coll-get
    [server-state (assoc m :status :ok
                         :value (get-in server-state
                                        [:realms (:cur-realm m)
                                         :collsets (:cur-realm-collset m)
                                         :colls (:cur-realm-collset-coll m)]))]

    [server-state (assoc m :status :invalid :status-info :invalid-op)]))

; --------------------------------------------

