Skip to content

Commit

Permalink
Updated client code to use new udp lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
oubiwann committed Jul 21, 2018
1 parent 7ffccae commit 18204d3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 58 deletions.
2 changes: 1 addition & 1 deletion config/sample/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
:ns [timi.server.cli]}}
:client {
:log {
:level :info
:level :debug
:ns [timi.client.cli]}}}}
1 change: 0 additions & 1 deletion dev-resources/src/timi/dev.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
[taoensso.timbre :as log]
[timi.server.cli.core :as cli]
[timi.server.cli.parser :as cli-parser]
[timi.server.cli.udp :as cli-server]
[timi.server.components.core :as components]
[timi.server.core :as timi]
[timi.server.util :as util]
Expand Down
5 changes: 3 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
[ring/ring-codec "1.0.1"]
[ring/ring-core "1.6.1"]
[selmer "1.10.7" :exclusions [joda-time]]
[systems.billo/async-udp "0.1.0"]
[systems.billo/async-udp "0.1.0-SNAPSHOT"]
[systems.billo/inet-address "0.1.1"]
[systems.billo/sockets "0.1.1"]]
:plugins [
Expand Down Expand Up @@ -174,14 +174,15 @@
"timi-figwheel" ["with-profile" "+local" "figwheel"]
"check-deps" ["with-profile" "+test" "ancient" "check" "all"]
"lint" ["with-profile" "+test" "kibit"]
"timi-build-cli" ["cljsbuild" "once" "cli"]
"timi-build" ["with-profile" "+build" "do"
;["check-deps"] XXX enable once clj-http 3.5.x is working with Tímı
["lint"]
["test"]
["compile"]
["uberjar"]
["cljsbuild" "once"]
["cljsbuild" "once" "cli"]]
["timi-build-cli"]]
"timi-deploy" ["with-profile" "build" "deploy" "clojars"]
"timi-server-docs" ["with-profile" "+build,+docs,+server-docs" "codox"]
"timi-client-docs" ["with-profile" "+build,+docs,+client-docs" "codox"]
Expand Down
4 changes: 2 additions & 2 deletions src/clj/timi/server/components/cli.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns timi.server.components.cli
(:require
[billo.udp.server :as cli-server]
[billo.udp.server.core :as cli-server]
[com.stuartsierra.component :as component]
[taoensso.timbre :as log]
[timi.server.cli.core :as cli]))
Expand All @@ -18,7 +18,7 @@
options {:port (get-in cfg [:cli :server :port])
:parser-fn cli-parser
:parser-opts {:config cfg}}
server (cli-server/run cfg opts)]
server (cli-server/run options)]
(log/trace "Using config:" cfg)
(log/trace "Using server options:" options)
(log/trace "Component keys:" (keys component))
Expand Down
20 changes: 7 additions & 13 deletions src/cljs/cli/timi/client/cli.cljs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
(ns timi.client.cli
(:require
[billo.udp.client.core :as udp]
[billo.udp.client.util :as util]
[cljs.nodejs :as node]
[clojure.string :as string]
[clojusc.twig :as logger]
[taoensso.timbre :as log]
[timi.client.config :as config]
[timi.client.udp :as udp]))
[timi.client.config :as config]))

;;; CLI setup and functions

Expand All @@ -14,14 +15,6 @@
(logger/set-level! (get-in config/data [:cli :client :log :ns])
(get-in config/data [:cli :client :log :level]))

(defn args->str
[args]
(str (string/join " "args) "\n"))

(defn wait
[]
(js/setTimeout #(log/info "UDP client timed out.")
3000))

;;; UDP Callback

Expand All @@ -40,9 +33,10 @@
[& args]
(log/debug "Got args:" args)
(let [client (udp/client)
data (args->str args)]
port (get-in config/data [:cli :server :port])
data (util/args->str args)]
(udp/on-receive client #(handle-receive client %))
(udp/send client config/data data)
(wait)))
(udp/send client port data)
(util/wait)))

(set! *main-cli-fn* -main)
3 changes: 1 addition & 2 deletions src/cljs/cli/timi/client/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
(:require
[clojure.string :as string]
[clojusc.twig :as logger]
[taoensso.timbre :as log]
[timi.client.tcp :as tcp]))
[taoensso.timbre :as log]))

(def fs (js/require "fs"))

Expand Down
37 changes: 0 additions & 37 deletions src/cljs/cli/timi/client/udp.cljs

This file was deleted.

0 comments on commit 18204d3

Please sign in to comment.