Index: clientmod.scm ================================================================== --- clientmod.scm +++ clientmod.scm @@ -33,14 +33,23 @@ (import scheme posix data-structures srfi-18 + typed-records artifacts servermod ) + +(defstruct con ;; client connection + (hdir #f) + (obj-to-str #f) + (host #f) + (pid #f) + (sdat #f) ;; server artifact data + ) (define (client:find-server areapath) (let* ((sdir (conc areapath"/.server")) (sarfs (glob (conc sdir"/*.artifact")))) ;; server artifacts (if (null? sarfs) @@ -48,11 +57,24 @@ (server:launch areapath) (thread-sleep! 1) (client:find-server areapath)) (let* ((sarf (car sarfs)) (sdat (read-artifact->alist sarf)) - (srvdir (alist-ref 'd sdat))) - srvdir)))) - - + (hdir (alist-ref 'd sdat))) + (make-con hdir: hdir sdat: sdat))))) + +(define (client:send-receive con cmd params) + (let* ((obj->string (con-obj-to-str con)) + (arf `((c . ,cmd) + (p . ,(obj->string params)) + (h . ,(con-host con)) + (i . ,(con-pid con)))) + (hdir (con-hdir con)) + (uuid (write-alist->artifact hdir arf ptype: 'Q))) + + ;; wait for a response here + + #f + )) + ) Index: rmtmod.scm ================================================================== --- rmtmod.scm +++ rmtmod.scm @@ -19,17 +19,26 @@ ;;====================================================================== (declare (unit rmtmod)) (declare (uses commonmod)) (declare (uses clientmod)) +(declare (uses dbmod)) (module rmtmod * (import scheme + chicken + data-structures + posix + srfi-1 + srfi-18 + srfi-69 + extras clientmod + dbmod ) ;; ;; THESE ARE ALL CALLED ON THE CLIENT SIDE!!! ;; @@ -43,24 +52,31 @@ ;;====================================================================== ;; if a server is either running or in the process of starting call client:setup ;; else return #f to let the calling proc know that there is no server available ;; -(define (rmt:get-connection-info areapath runremote) ;; TODO: push areapath down. - (client:find-server areapath) +(define (rmt:get-connection-info areapath) ;; TODO: push areapath down. + (if *runremote* + *runremote* + (begin + (set! *runremote* (client:find-server areapath)) + (con-obj-to-str-set! *runremote* db:obj->str) + (con-host-set! *runremote* (get-host-name)) + (con-pid-set! *runremote* (current-process-id)) + *runremote*))) + #;(let* ((cinfo (if (remote? runremote) (remote-conndat runremote) #f))) (if cinfo cinfo (if (server:check-if-running areapath) (client:setup areapath runremote) - #f)))) + #f))) (define (rmt:on-homehost? runremote) #t - ) #;(let* ((hh-dat (remote-hh-dat runremote))) (if (pair? hh-dat) (cdr hh-dat) (begin (debug:print-info 0 *default-log-port* "hh-dat="hh-dat) @@ -70,10 +86,14 @@ ;;====================================================================== (define *send-receive-mutex* (make-mutex)) ;; should have separate mutex per run-id (define (rmt:send-receive cmd rid params #!key (attemptnum 1)) ;; start attemptnum at 1 so the modulo below works as expected + (let* ((con (rmt:get-connection-info areapath))) + (client:send-receive con cmd params))) + + ;; RA => e.g. usage (rmt:send-receive 'get-var #f (list varname)) ;; ;; (define (rmt:send-receive cmd rid params #!key (attemptnum 1)(area-dat #f)) ;; start attemptnum at 1 so the modulo below works as expected ;; #;(common:telemetry-log (conc "rmt:"(->string cmd))