Created
December 18, 2017 19:40
-
-
Save maruks/a5359ade5af71bc47dcf2dbc5c487203 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns prison.core | |
(:require [gniazdo.core :as ws] | |
[clojure.data.json :as json])) | |
(defn parse [str] | |
(json/read-str str :key-fn keyword)) | |
(def msg-atom (atom nil)) | |
(defn handle [msg] | |
(reset! msg-atom msg) | |
(ws/send-msg socket (json/write-str {:tag "SetColor" :contents "#0000ff"})) | |
(ws/send-msg socket (json/write-str {:tag "MakeChoice" :contents ["Betray" "North"]})) | |
(ws/send-msg socket (json/write-str {:tag "MakeChoice" :contents ["Betray" "South"]})) | |
(ws/send-msg socket (json/write-str {:tag "MakeChoice" :contents ["Betray" "West"]})) | |
(ws/send-msg socket (json/write-str {:tag "MakeChoice" :contents ["Betray" "East"]}))) | |
(defonce socket | |
(ws/connect | |
"ws://game.clearercode.com:8000" | |
:on-receive #(handle (parse %)))) | |
#_( | |
(ws/send-msg socket "hello") | |
(ws/close socket) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment