         [:li (when (#{:home-page :tables-page :play-page} current-page) {:class "active"})
          [:a {:href "/play"} "Play"]]
         [:li (when (= current-page :about-page) {:class "active"})
-         [:a {:href "/about"} "About"]]]]]]))
+         [:a {:href "/about"} "About"]]]
+       (when (:loggedin @state)
+         [:p.navbar-text.navbar-right (str "Signed in as " (:username @state))])]]]))
 
 (declare connect!)
 


(defonce app-state (atom {}))

(defn nav-bar [_]
  (let [current-page (session/get :current-page)]
    [:nav.navbar.navbar-default.navbar-static-top
     [:div.container

  (reset! state {})
  (session/put! :current-page :home-page))

(defn last-game [state]
  (swap! state assoc-in [:play-page :last-game] true))

(defn handle-message [state [m1 m2 :as msg]]
  (println "message" msg)
  (cond
    (= m1 "ok") (cond
                  (= m2 "login") (logged-in state)
                  (= m2 "logout") (logged-out state)
                  (= m2 "join") (table-joined state)
                  (= m2 "leave") (table-left state)
                  (= m2 "last_game") (last-game state)
                  (or (= m2 "lielais")
                      (= m2 "zole")
                      (= m2 "pass")) (swap! state assoc-in [:play-page :prompt] nil)
                  (= m2 "tables") (session/put! :current-page :tables-page)
                  (= m2 "save") (do (swap! state assoc-in [:play-page :saved] nil)
                                    (swap! state assoc-in [:play-page :prompt] nil)))

    (= m1 "tables") (swap! state assoc-in [:tables-page :tables] (sort-by :name (map (fn [[table players]] {:name table :players (apply str (interpose \, players))}) m2)))
    (= m1 "open_tables") (swap! state assoc-in [:tables-page :tables] (sort-by :name (map (fn [[table players]] {:name table :players (apply str (interpose \, players))}) m2)))
    (= m1 "cards") (swap! state assoc-in [:play-page :cards] m2)
    (= m1 "players") (start-game state m2)
    (= m1 "last_game") (last-game state)
    (= m1 "prompt") (swap! state assoc-in [:play-page :prompt] m2)
    (= m1 "plays") (plays state msg)
    (= m1 "wins") (swap! state assoc-in [:play-page :plays] {})
    (= m1 "game_type") (swap! state assoc-in [:play-page :game-type] (rest msg))
    (= m1 "table_closed") (swap! state assoc-in [:play-page :prompt] :table-closed)
    (= m1 "end_of_game") (end-of-game state msg)

    (= msg ["error" "already_registered" "login"]) (error-alert state (gstring/format "Username '%s' is already taken." (:username @state)))

    :else (println "unknown message" msg)))

(defn handle-error [state err]
