Compare commits

...

1 Commits

Author SHA1 Message Date
vkz 423de37248 Chat-server processes now on ground-vm, no at-meta-level necessary 2013-10-09 17:53:59 -04:00
1 changed files with 11 additions and 11 deletions

View File

@ -1,11 +1,11 @@
#lang marketplace #lang marketplace
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(spawn-vm
(at-meta-level
(observe-publishers (tcp-channel ? (tcp-listener 5999) ?) (observe-publishers (tcp-channel ? (tcp-listener 5999) ?)
(match-conversation (tcp-channel them us _) (match-conversation (tcp-channel them us _)
(on-presence (spawn (chat-session them us))))))) (on-presence (spawn (chat-session them us)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (chat-session them us) (define (chat-session them us)
@ -17,27 +17,27 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (listen-to-user user them us) (define (listen-to-user user them us)
(list (list
(at-meta-level
(subscriber (tcp-channel them us ?) (subscriber (tcp-channel them us ?)
(on-absence (quit)) (on-absence (quit))
(on-message (on-message
[(tcp-channel _ _ (? bytes? text)) [(tcp-channel _ _ (? bytes? text))
(send-message `(,user says ,text))]))) (send-message `(,user says ,text))]))
(publisher `(,user says ,?)))) (publisher `(,user says ,?))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (speak-to-user user them us) (define (speak-to-user user them us)
(define (say fmt . args) (define (say fmt . args)
(at-meta-level
(send-message (send-message
(tcp-channel us them (apply format fmt args))))) (tcp-channel us them (apply format fmt args))))
(define (announce who did-what) (define (announce who did-what)
(unless (equal? who user) (unless (equal? who user)
(say "~s ~s.~n" who did-what))) (say "~s ~s.~n" who did-what)))
(list (list
(say "You are ~s.~n" user) (say "You are ~s.~n" user)
(at-meta-level
(publisher (tcp-channel us them ?))) (publisher (tcp-channel us them ?))
(subscriber `(,? says ,?) (subscriber `(,? says ,?)
(match-conversation `(,who says ,_) (match-conversation `(,who says ,_)
(on-presence (announce who 'arrived)) (on-presence (announce who 'arrived))