Created
April 9, 2012 21:59
-
-
Save ulsa/2346853 to your computer and use it in GitHub Desktop.
ClojureScript code for accessing the Karotz toy rabbit
This file contains 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 clojurekarotz.core | |
(:require [clojurekarotz.util :as u])) | |
(def quit (fn [event] (if (= event "TERMINATED") (js/exit)))) | |
(defn onKarotzConnect [data] | |
(.moveRelative (.-ears js/karotz) 5 -5 (fn [_])) | |
(.start (.-tts js/karotz) "Buenos dias Clojure. Como estas? Tienes animales?" "es" quit)) | |
(.connectAndStart js/karotz "192.168.1.13" 9123 onKarotzConnect (js-obj)) |
This file contains 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
var karotz = {}; | |
karotz.connect = function() {}; | |
karotz.start = function() {}; | |
karotz.ears = function() {}; | |
karotz.ears.moveRelative = function() {}; | |
karotz.tts = function() {}; | |
karotz.tts.start = function() {}; |
This file contains 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
(defproject clojurekarotz "1.0.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:plugins [[lein-cljsbuild "0.1.6"]] | |
:dependencies [[org.clojure/clojure "1.3.0"]] | |
:cljsbuild { | |
:builds [ | |
{:source-path "src" | |
:compiler {:output-to "main.js" | |
:optimizations :advanced | |
:pretty-print false | |
:externs ["externs.js"]}}]}) |
This file contains 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 clojurekarotz.util) | |
(set! (.-connectAndStart js/karotz) | |
(fn [host port callback data] | |
(try | |
(.connect js/karotz host port) | |
(js/log "connected") | |
(.start js/karotz callback data) | |
(catch js/Error e | |
(js/log e))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment