X-Git-Url: https://jxself.org/git/?p=mudsync.git;a=blobdiff_plain;f=mudsync%2Fnetworking.scm;h=4417cfd27e898f4061992aad69bc65f820c58216;hp=1c28b38dcbb4ef872c8e1663e5fa12dac2eb6329;hb=0ea9e56921f887613da5472f12c1e2ae229cb829;hpb=18c74950d1bd9fc915411bde06b99a273b55ae25 diff --git a/mudsync/networking.scm b/mudsync/networking.scm index 1c28b38..4417cfd 100644 --- a/mudsync/networking.scm +++ b/mudsync/networking.scm @@ -206,21 +206,20 @@ (pk 'web-server (create-actor nm #:port web-server-port #:http-handler (wrap-apply http-handler) - #:websocket-handler (wrap-apply websocket-handler))))) + #:on-ws-message (wrap-apply websocket-new-message))))) (define (view:main-display request body) (define one-entry - '(div (@ (class "stream-entry")) - (p "This is an entry!") - (p "Let's try a few paragraphs") - (p "okay?"))) + '(div (@ (class "stream-entry")) + (p (b "") " Wow, it's so shiny!"))) (define body-tmpl `((div (@ (id "stream-metabox")) (div (@ (id "stream")) - ,@(map (const one-entry) (iota 10)))) + ,@(map (const one-entry) (iota 25)) + (div (@ (class "stream-entry")) + (p (b "") " Last one!")))) (div (@ (id "input-metabox")) - (p "test test") (input (@ (id "input")))))) (define (main-tmpl) @@ -271,7 +270,9 @@ ;; Respond to text messages by reversing the message. Respond to ;; binary messages with "hello". -(define (websocket-handler data) - (if (string? data) - (string-reverse data) - "hello")) +(define (websocket-new-message websocket-server client-id data) + (<- (actor-id websocket-server) 'ws-send + client-id + (if (string? data) + (string-reverse data) + "hello")))