2013-04-26 21:43:25 +00:00
|
|
|
#lang racket/base
|
|
|
|
;; Plain Racket version, using (require) instead of #lang marketplace.
|
|
|
|
|
|
|
|
(require marketplace/sugar-untyped)
|
|
|
|
(require marketplace/drivers/tcp-bare)
|
|
|
|
|
|
|
|
(define (echoer from to)
|
|
|
|
(transition/no-state
|
2013-06-08 01:01:55 +00:00
|
|
|
(publisher (tcp-channel to from ?))
|
2013-06-07 21:46:20 +00:00
|
|
|
(subscriber (tcp-channel from to ?)
|
2013-06-03 18:57:42 +00:00
|
|
|
(on-absence (quit))
|
|
|
|
(on-message
|
|
|
|
[(tcp-channel _ _ data)
|
|
|
|
(send-message (tcp-channel to from data))]))))
|
2013-04-26 21:43:25 +00:00
|
|
|
|
|
|
|
(ground-vm tcp
|
2014-03-09 19:44:16 +00:00
|
|
|
(observe-publishers (tcp-channel ? (tcp-listener 5999) ?)
|
2013-06-03 18:57:42 +00:00
|
|
|
(match-conversation (tcp-channel from to _)
|
|
|
|
(on-presence (spawn (echoer from to))))))
|