             [reagent.core :as reagent :refer [atom]])
   (:require-macros [cljs.core.async.macros :refer [go go-loop]]))
 
-(defn opponend-field []
-  [:div.opponent-field
-   [:h1 "TEST!!!"]])
+(defn init-ws-connection! []
+  (go
+    (let [{:keys [ws-channel error]} (<! (ws-ch "ws://localhost:8080/ws"
+                                                {:format :json-kw}))]
+      (if-not error
+        ws-channel
+        (js/alert "Error:" (pr-str error))))))
+
+;; (defn client-ws-handler []
+;;   (go
+;;     (let [{:keys [ws-channel error]} (<! ws)]
+;;       (if error
+;;         (js/alert (pr-str error))
+;;         (loop []
+;;           (<! (timeout 1000))
+;;           (recur))))))
+
+;; (set! (.-onload js/window)
+;;       client-ws-handler)
+
+(defn opponent-field []
+  [:div.opponent-field])
 
 (defn field []
   [:div.field])

(defn legend []
  [:div.legend])

(defn game []
  [:section#game
   [opponent-field]

   [hand]
   [legend]]
  [:div#flyingCards]
  [login-form])

(reagent/render-component [game] (.getElementById js/document "app"))
