2017-08-10 19:04:45 +00:00
|
|
|
#lang syndicate/core
|
2015-08-18 16:45:29 +00:00
|
|
|
|
2016-07-30 17:02:07 +00:00
|
|
|
(require syndicate/protocol/advertise)
|
2016-07-12 19:05:56 +00:00
|
|
|
(require/activate "../drivers/tcp.rkt")
|
2015-08-18 16:45:29 +00:00
|
|
|
(require "../demand-matcher.rkt")
|
|
|
|
|
|
|
|
(define server-id (tcp-listener 5999))
|
|
|
|
|
|
|
|
(spawn-demand-matcher (advertise (tcp-channel (?!) server-id ?))
|
|
|
|
(observe (tcp-channel (?!) server-id ?))
|
|
|
|
(lambda (c)
|
|
|
|
(printf "Accepted connection from ~v\n" c)
|
2017-02-15 23:18:19 +00:00
|
|
|
(actor (lambda (e state)
|
2015-08-18 16:45:29 +00:00
|
|
|
(match e
|
|
|
|
[(? patch/removed?)
|
|
|
|
(printf "Closed connection ~v\n" c)
|
|
|
|
(quit)]
|
|
|
|
[(message (tcp-channel src dst bs))
|
|
|
|
(transition state (message (tcp-channel dst src bs)))]
|
|
|
|
[_ #f]))
|
|
|
|
(void)
|
2015-12-03 20:53:07 +00:00
|
|
|
(patch-seq (sub (advertise (tcp-channel c server-id ?)))
|
|
|
|
(sub (tcp-channel c server-id ?))
|
|
|
|
(pub (tcp-channel server-id c ?))))))
|