Use actor macro

This commit is contained in:
Tony Garnock-Jones 2014-06-22 22:49:13 -04:00
parent ceef225fce
commit b928d6c78a
1 changed files with 5 additions and 10 deletions

View File

@ -4,13 +4,8 @@
(spawn-udp-driver)
(spawn (lambda (e s)
(match e
[(message (udp-packet src dst body) _ _)
(log-info "Got packet from ~v: ~v" src body)
(transition s (send (udp-packet dst
src
(string->bytes/utf-8 (format "You said: ~a" body)))))]
[_ #f]))
(void)
(gestalt-union (sub (udp-packet ? (udp-listener 5999) ?))))
(actor #:name echoer
(subscribe (udp-packet ($ src) ($ dst (udp-listener 5999)) ($ body))
(log-info "Got packet from ~v: ~v" src body)
(define reply (string->bytes/utf-8 (format "You said: ~a" body)))
(send (udp-packet dst src reply))))