marketplace-2014/marketplace/support/spy.rkt

33 lines
907 B
Racket
Raw Normal View History

2013-03-29 03:00:29 +00:00
#lang typed/racket/base
(require "../sugar-typed.rkt")
(provide generic-spy)
(: generic-spy : (All (ParentState) Any -> (Spawn ParentState)))
(define (generic-spy label)
(spawn: #:debug-name `(generic-spy ,label)
#:parent : ParentState
#:child : Void
(transition: (void) : Void
(endpoint: : Void
#:subscriber (wild) #:observer
#:peer-orientation orientation
#:conversation topic
#:peer-interest-type interest
#:reason reason
#:on-presence (begin (write `(,label ENTER (,orientation ,topic ,interest)))
(newline)
(flush-output)
'())
#:on-absence (begin (write `(,label EXIT (,orientation ,topic ,interest)))
(newline)
(display reason)
(newline)
(flush-output)
'())
[p (begin (write `(,label MSG ,p))
(newline)
(flush-output)
'())]))))