From 5fca0d7aac247c8ddcf35fc40fbd0623f091c217 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 16 Jul 2012 17:07:42 -0400 Subject: [PATCH] Tweak to presence notification --- chat-os2.rkt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chat-os2.rkt b/chat-os2.rkt index 3e16ec0..437a954 100644 --- a/chat-os2.rkt +++ b/chat-os2.rkt @@ -20,6 +20,7 @@ (match-define (topic _ (tcp-channel connection-id _ _) _) t) (define-values (cin cout in-topic out-topic) (tcp-accept t)) (transition 'no-state + (at-meta-level (cout (term->bytes `(you-are ,connection-id)))) (at-meta-level (cin (tcp-mode 'lines))) (at-meta-level (cin (tcp-credit 1))) (at-meta-level (role/anon out-topic)) @@ -32,9 +33,8 @@ (role/anon (topic-subscriber `(,(wild) says ,(wild))) #:topic t #:on-presence (match t [(topic _ `(,who ,_ ,_) _) - (at-meta-level (cout (term->bytes (if (equal? who connection-id) - `(you-are ,connection-id) - `(,who arrived)))))]) + (when (not (equal? who connection-id)) + (at-meta-level (cout (term->bytes `(,who arrived)))))]) #:on-absence (match t [(topic _ `(,who ,_ ,_) _) (when (not (equal? who connection-id)) (at-meta-level (cout (term->bytes `(,who departed)))))])