Tweak to presence notification
This commit is contained in:
parent
59469d68f8
commit
5fca0d7aac
|
@ -20,6 +20,7 @@
|
||||||
(match-define (topic _ (tcp-channel connection-id _ _) _) t)
|
(match-define (topic _ (tcp-channel connection-id _ _) _) t)
|
||||||
(define-values (cin cout in-topic out-topic) (tcp-accept t))
|
(define-values (cin cout in-topic out-topic) (tcp-accept t))
|
||||||
(transition 'no-state
|
(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-mode 'lines)))
|
||||||
(at-meta-level (cin (tcp-credit 1)))
|
(at-meta-level (cin (tcp-credit 1)))
|
||||||
(at-meta-level (role/anon out-topic))
|
(at-meta-level (role/anon out-topic))
|
||||||
|
@ -32,9 +33,8 @@
|
||||||
(role/anon (topic-subscriber `(,(wild) says ,(wild)))
|
(role/anon (topic-subscriber `(,(wild) says ,(wild)))
|
||||||
#:topic t
|
#:topic t
|
||||||
#:on-presence (match t [(topic _ `(,who ,_ ,_) _)
|
#:on-presence (match t [(topic _ `(,who ,_ ,_) _)
|
||||||
(at-meta-level (cout (term->bytes (if (equal? who connection-id)
|
(when (not (equal? who connection-id))
|
||||||
`(you-are ,connection-id)
|
(at-meta-level (cout (term->bytes `(,who arrived)))))])
|
||||||
`(,who arrived)))))])
|
|
||||||
#:on-absence (match t [(topic _ `(,who ,_ ,_) _)
|
#:on-absence (match t [(topic _ `(,who ,_ ,_) _)
|
||||||
(when (not (equal? who connection-id))
|
(when (not (equal? who connection-id))
|
||||||
(at-meta-level (cout (term->bytes `(,who departed)))))])
|
(at-meta-level (cout (term->bytes `(,who departed)))))])
|
||||||
|
|
Loading…
Reference in New Issue