Ok, I got this working too. Turns out that *namespaced keywords* do not keep their namespaces as they are transferred from Clojurescript, over to Clojure-land. This was causing my named remote function, not to be seen. Anyways, hopefully this can help someone in future.
Cheers Tim On Mon, May 6, 2013 at 1:59 PM, Timothy Washington <twash...@gmail.com>wrote: > Ok, I got this sorted. > > *A)* I used :optimizations :simple , and the JS files are separated out > *B)* There was a stale version of clojurescript referenced in my > project.clj file. I just removed that, cleaned out gen'd files with `lein > cljsbuild clean`, then iii) `lein cljsbuild (once|auto)`. > > > Then my edgar.js loads as expected. HTH. > > > *BUT*, now when my client tries to go to "* > http://localhost:8080/_shoreleave*", it gets a 404, "*Remote not found.*" > error. Now the marginali docs (see > here<http://shoreleave.github.io/shoreleave-remote-ring/>) > show that the function wrap-rpc, should be setting up that just remote. Is > there any other magic I need to throw in? > > > (ns edgar.handler > (:gen-class) > (:import [java.io File]) > (:use [clojure.core.strint] > [compojure.core] > [ring.middleware.params] > [ring.middleware.multipart-params] > [ring.adapter.jetty]) > (:require [clojure.tools.logging :as log] > [compojure.handler :as handler] > [compojure.route :as route] > [ring.util.response :as ring-response] > [clojure.java.io :as io] > [shoreleave.middleware.rpc :as rpc] > )) > > (defn *remote-fn* [arg1 & remaining] > "thing") > > (rpc/defremote ^{:remote-name :handler/heartbeat} *remote-fn*) > > (defroutes *app-routes* > (GET "/" [] (ring-response/file-response "include/index.html" { > :root "public"})) > (route/files "/" { :root "public"}) > (route/resources "/" { :root "public"}) > (route/not-found "Not Found")) > > (def app > (-> *app-routes* > *rpc/wrap-rpc* > handler/site > wrap-params > wrap-multipart-params > )) > > (defn -main [] > (let [port (Integer. (get (System/getenv) "PORT" "8080"))] > (run-jetty app {:port port :join? false}))) > > *handler.clj* > > > Thanks > Tim > > > On Mon, May 6, 2013 at 12:14 PM, Timothy Washington <twash...@gmail.com>wrote: > >> Hi there, >> >> I'm trying to use >> shoreleave-remote<https://github.com/shoreleave/shoreleave-remote>(and >> shoreleave-remote-ring<https://github.com/shoreleave/shoreleave-remote-ring/>) >> in my Clojurescript application, and am running into a few problems. >> >> >> >> *A)* With the i) Clojurescript and ii) HTML code below, in Chrome, >> main.js gives me the error "Uncaught Error: Namespace "edgar" already >> declared.". I'm using lein-cljsbuild, and this happens whether compiled >> with :optimizations :whitespace or :advanced. >> >> (ns edgar >> (:require-macros [shoreleave.remotes.macros :as macros]) >> (:require [clojure.browser.repl :as repl] >> [shoreleave.remotes.http-rpc :as rpc])) >> >> (rpc/remote-callback :handler/heartbeat ["heartbeat"] >> #(js/alert %)) >> >> *edgar.cljs* >> >> >> <html> >> >> >> >> >> >> <head> >> >> >> >> >> >> <meta charset='UTF-8'> >> >> >> >> >> >> <title>Edgar: At your command</title> >> >> >> >> >> >> </head> >> >> >> >> >> >> <body> >> >> >> >> >> >> <div id='content'> >> >> >> >> >> >> <script src='javascript/main.js' type='text/javascript'></script> >> >> >> >> >> >> <script src='javascript/edgar.js' >> type='text/javascript'></script> >> >> >> >> >> <script type='text/javascript'> >> >> >> >> >> >> goog.require("edgar") >> >> >> >> >> >> </script> >> >> >> >> >> >> </div> >> >> >> >> >> >> </body> >> >> >> >> >> >> </html> >> >> *index.html* >> >> (ns edgar.handler ...) >> >> >> >> >> >> >> (rpc/defremote ^{:remote-name :handler/heartbeat} remote-fn [arg1 & >> remaining] >> "fubar" ) >> >> >> >> >> >> >> (defroutes app-routes >> >> >> >> >> >> (GET "/" [] >> (ring-response/file-response "include/index.html" { :root >> "public"})) >> .... >> ) >> >> >> >> >> >> >> (def app >> (-> app-routes >> rpc/wrap-rpc >> wrap-params >> wrap-multipart-params >> handler/site)) >> >> >> >> >> >> >> (defn -main [] >> (let [port (Integer. (get (System/getenv) "PORT" "8080"))] >> (run-jetty app {:port port :join? false}))) >> >> *handler.clj ( ... for good measure )* >> >> >> >> *B)* Next, calling those remotes seems to be a problem. In the generated >> main.js file, the error "Uncaught TypeError: Cannot call method 'call' >> of undefined" is produced from the line in fig.1. I checked, and this >> error is i) happening before any network calls are made and ii) coming from >> the bottom of the generated main.js file (see fig.2, which is strangely >> similar to the generated edgar,js file). >> >> >> >> shoreleave.remotes.protocols._data_str["_"] = function(t) { >> return[cljs.core.str(goog.Uri.QueryData.createFromMap(new >> goog.structs.Map(shoreleave.remotes.common.clj__GT_js.*call*(null, >> t))))].join("") >> }; >> >> fig.1 >> >> ... >> goog.provide("edgar"); >> goog.require("cljs.core"); >> goog.require("shoreleave.remotes.http_rpc"); >> goog.require("clojure.browser.repl"); >> shoreleave.remotes.http_rpc.remote_callback.call(null, "\ufdd0'handler/ >> heartbeat", cljs.core.PersistentVector.fromArray(["heartbeat"], true), >> function(p1__5971_SHARP_) { >> return alert(p1__5971_SHARP_) >> }); >> >> fig.2 >> >> >> >> >> Any insights on these? Thanks in advance >> >> >> Tim Washington >> Interruptsoftware.ca >> >> No 6: "I'm not a number. I'M A FREE MAN!!!" >> No 2: "HA HA HA HA HAAAAAAA" >> >> -- The Prisoner >> > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.