X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=mudsync%2Fnetworking.scm;h=d2593d11e2f92784b9b73803504a325bc248b499;hb=e6bd5ce0dd5edd77d182f70e6a32101e999f8623;hp=4714556b4427595ec1e1b1ee2694880bd5be8bd2;hpb=ca990b14f563fc450548954184ff6fc0e4792739;p=mudsync.git diff --git a/mudsync/networking.scm b/mudsync/networking.scm index 4714556..d2593d1 100644 --- a/mudsync/networking.scm +++ b/mudsync/networking.scm @@ -17,7 +17,7 @@ ;;; along with Mudsync. If not, see . (define-module (mudsync networking) - #:use-module (8sync systems actors) + #:use-module (8sync actors) #:use-module (8sync agenda) #:use-module (ice-9 format) #:use-module (ice-9 match) @@ -49,7 +49,7 @@ (actions #:allocation #:each-subclass #:init-value - (mhandlers + (build-actions (start-listening (lambda* (actor message #:key (server %default-server) @@ -135,7 +135,7 @@ (sockaddr:addr client-details))) (fcntl client F_SETFL (logior O_NONBLOCK (fcntl client F_GETFL))) (hash-set! (nm-clients nm) client-id client) - (<- nm (nm-send-input-to nm) 'new-client #:client client-id) + (<-* `(#:actor ,nm) (nm-send-input-to nm) 'new-client #:client client-id) (nm-client-receive-loop nm client client-id)) (define (nm-client-receive-loop nm client client-id) @@ -147,25 +147,27 @@ (begin (nm-handle-line nm client client-id (string-trim-right line #\return)) - (loop)))) + (when (actor-alive? nm) + (loop))))) (loop)) (define (nm-handle-port-closed nm client client-id) "Handle a closed port" (format #t "DEBUG: handled closed port ~x\n" client-id) (hash-remove! (nm-clients nm) client-id) - (<- nm (nm-send-input-to nm) 'client-closed #:client client-id)) + (<-* `(#:actor ,nm) (nm-send-input-to nm) 'client-closed #:client client-id)) (define-method (nm-handle-port-eof nm client client-id) "Handle seeing an EOF on port" (format #t "DEBUG: handled eof-object on port ~x\n" client-id) (close client) (hash-remove! (nm-clients nm) client-id) - (<- nm (nm-send-input-to nm) 'client-closed #:client client-id)) + (<-* `(#:actor ,nm) (nm-send-input-to nm) 'client-closed + #:client client-id)) (define-method (nm-handle-line nm client client-id line) "Handle an incoming line of input from a client" - (<- nm (nm-send-input-to nm) 'client-input + (<-* `(#:actor ,nm) (nm-send-input-to nm) 'client-input #:data line #:client client-id))