From 423de372488541bf723cc1fa1963cb9fe047a3ca Mon Sep 17 00:00:00 2001 From: vkz Date: Wed, 9 Oct 2013 17:53:59 -0400 Subject: [PATCH] Chat-server processes now on ground-vm, no at-meta-level necessary --- examples/chat-paper.rkt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/chat-paper.rkt b/examples/chat-paper.rkt index 8bc50f2..db904a6 100644 --- a/examples/chat-paper.rkt +++ b/examples/chat-paper.rkt @@ -1,11 +1,11 @@ #lang marketplace ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(spawn-vm - (at-meta-level - (observe-publishers (tcp-channel ? (tcp-listener 5999) ?) - (match-conversation (tcp-channel them us _) - (on-presence (spawn (chat-session them us))))))) + + +(observe-publishers (tcp-channel ? (tcp-listener 5999) ?) + (match-conversation (tcp-channel them us _) + (on-presence (spawn (chat-session them us))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (chat-session them us) @@ -17,27 +17,27 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (listen-to-user user them us) (list - (at-meta-level + (subscriber (tcp-channel them us ?) (on-absence (quit)) (on-message [(tcp-channel _ _ (? bytes? text)) - (send-message `(,user says ,text))]))) + (send-message `(,user says ,text))])) (publisher `(,user says ,?)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (speak-to-user user them us) (define (say fmt . args) - (at-meta-level + (send-message - (tcp-channel us them (apply format fmt args))))) + (tcp-channel us them (apply format fmt args)))) (define (announce who did-what) (unless (equal? who user) (say "~s ~s.~n" who did-what))) (list (say "You are ~s.~n" user) - (at-meta-level - (publisher (tcp-channel us them ?))) + + (publisher (tcp-channel us them ?)) (subscriber `(,? says ,?) (match-conversation `(,who says ,_) (on-presence (announce who 'arrived))