Tweak to presence notification

This commit is contained in:
Tony Garnock-Jones 2012-07-16 17:07:42 -04:00
parent 59469d68f8
commit 5fca0d7aac
1 changed files with 3 additions and 3 deletions

View File

@ -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)))))])