diff options
author | David Barksdale <amatus@amatus.name> | 2014-01-01 11:39:30 -0600 |
---|---|---|
committer | David Barksdale <amatus@amatus.name> | 2014-01-01 12:06:50 -0600 |
commit | 5e4828acafee47704bd6df97806fa72927ede852 (patch) | |
tree | 0c32316b25074d4cc97bf441fc1cb496c9a1d0da | |
parent | 2500888f7aa39a88e2c77ac7c36c0c4b6c70804a (diff) |
Write ats as a cljs service.
I couldn't figure out how to get dlopen working, so this is
going to be faked out for now.
-rwxr-xr-x | build-gnunet.sh | 21 | ||||
-rw-r--r-- | src/cljs/gnunet_web/ats.cljs | 36 | ||||
-rw-r--r-- | src/cljs/gnunet_web/ui.cljs | 8 | ||||
-rw-r--r-- | src/js/client.js | 10 |
4 files changed, 49 insertions, 26 deletions
diff --git a/build-gnunet.sh b/build-gnunet.sh index 40349a5..3c787f1 100755 --- a/build-gnunet.sh +++ b/build-gnunet.sh @@ -174,6 +174,7 @@ tar -zxf "../downloads/$LIBTOOL_TGZ" || die "Unable to extract $LIBTOOL_TGZ" cd "$LIBTOOL_SRCDIR" emconfigure ./configure --prefix="$SYSROOT" \ + lt_cv_path_NM="llvm-nm -B" \ ac_cv_func_argz_append=no \ ac_cv_func_argz_create_sep=no \ ac_cv_func_argz_insert=no \ @@ -224,7 +225,7 @@ emmake make \ die "Unable to make GNUnet" # Link gnunet services and install them into resources/public/js mkdir -p "$BUILDROOT/resources/public/js" -./libtool --tag=CC --mode=link \ +"$SYSROOT/bin/libtool" --tag=CC --mode=link \ emcc -fno-strict-aliasing -Wall "-I$SYSROOT/include" "-L$SYSROOT/lib" \ -o src/transport/gnunet-service-transport.js \ src/transport/gnunet_service_transport-gnunet-service-transport*.o \ @@ -244,24 +245,6 @@ mkdir -p "$BUILDROOT/resources/public/js" --pre-js "$BUILDROOT/src/js/pre.js" cp src/transport/.libs/gnunet-service-transport.js \ "$BUILDROOT/resources/public/js/" -./libtool --tag=CC --mode=link \ - emcc -fno-strict-aliasing -Wall "-I$SYSROOT/include" "-L$SYSROOT/lib" \ - -o src/ats/gnunet-service-ats.js \ - src/ats/gnunet-service-ats*.o \ - src/ats/libgnunetats.la \ - src/statistics/libgnunetstatistics.la \ - src/util/libgnunetutil.la \ - "$SYSROOT/lib/libgcrypt.la" \ - "$SYSROOT/lib/libgpg-error.la" \ - -lm -lsocket \ - --js-library "$BUILDROOT/src/js/client.js" \ - --js-library "$BUILDROOT/src/js/configuration.js" \ - --js-library "$BUILDROOT/src/js/scheduler.js" \ - --js-library "$BUILDROOT/src/js/server.js" \ - --js-library "$BUILDROOT/src/js/service.js" \ - --pre-js "$BUILDROOT/src/js/pre.js" -cp src/ats/.libs/gnunet-service-ats.js \ - "$BUILDROOT/resources/public/js/" # Copy HELLOs for dev webserver cat contrib/hellos/* > "$BUILDROOT/resources/public/hostlist" cd "$BUILDROOT" diff --git a/src/cljs/gnunet_web/ats.cljs b/src/cljs/gnunet_web/ats.cljs new file mode 100644 index 0000000..64ce7ab --- /dev/null +++ b/src/cljs/gnunet_web/ats.cljs @@ -0,0 +1,36 @@ +;; ats.cljs - ATS service for gnunet-web website +;; Copyright (C) 2014 David Barksdale <amatus@amatus.name> +;; +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +(ns gnunet-web.ats + (:use [gnunet-web.service :only (add-service)])) + +(def ats-message-channel (js/MessageChannel.)) +(def clients (atom #{})) + +(defn client-get-message + [output event] + (output (str "ats-msg:" (js/JSON.stringify (.-data event))))) + +(defn start-ats + [output] + (set! (.-onmessage (.-port1 ats-message-channel)) + (fn [event] + ;; This must be a connect message + (let [port (.-port (.-data event))] + (swap! clients conj port) + (set! (.-onmessage port) (partial client-get-message output))))) + (add-service "ats" (.-port2 ats-message-channel))) + diff --git a/src/cljs/gnunet_web/ui.cljs b/src/cljs/gnunet_web/ui.cljs index ec42065..442665a 100644 --- a/src/cljs/gnunet_web/ui.cljs +++ b/src/cljs/gnunet_web/ui.cljs @@ -1,5 +1,5 @@ ;; ui.cljs - UI routines for gnunet-web website -;; Copyright (C) 2013 David Barksdale <amatus@amatus.name> +;; Copyright (C) 2013,2014 David Barksdale <amatus@amatus.name> ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -15,9 +15,10 @@ ;; along with this program. If not, see <http://www.gnu.org/licenses/>. (ns gnunet-web.ui - (:use [gnunet-web.service :only (client-connect)] + (:use [gnunet-web.ats :only (start-ats)] + [gnunet-web.hostlist :only (fetch-and-process!)] [gnunet-web.peerinfo :only (start-peerinfo)] - [gnunet-web.hostlist :only (fetch-and-process!)])) + [gnunet-web.service :only (client-connect)])) (defn by-id [id] @@ -30,6 +31,7 @@ (str (.-textContent output) "\n" string)))) (start-peerinfo output) +(start-ats output) (def transport-message-channel (js/MessageChannel.)) (def transport-port (.-port1 transport-message-channel)) (set! (.-onmessage transport-port) diff --git a/src/js/client.js b/src/js/client.js index 32542a1..6d71165 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -36,10 +36,12 @@ mergeInto(LibraryManager.library, { Runtime.stackRestore(stack); }; var delay = getValue(timeout, 'i64'); - setTimeout(function() { - CLIENT_PORTS[client].onmessage = null; - Runtime.dynCall('vii', handler, [handler_cls, 0]); - }, delay / 1000); + if (-1 != delay) { + setTimeout(function() { + CLIENT_PORTS[client].onmessage = null; + Runtime.dynCall('vii', handler, [handler_cls, 0]); + }, delay / 1000); + } }, GNUNET_CLIENT_notify_transmit_ready__deps: ['$CLIENT_PORTS'], GNUNET_CLIENT_notify_transmit_ready: function(client, size, timeout, |