No longer need inbound flag on tcp-data, since streams are directional now
This commit is contained in:
parent
23a8237a9a
commit
ffe06a65a8
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
(struct tcp-option (name value) #:prefab)
|
(struct tcp-option (name value) #:prefab)
|
||||||
(struct tcp-credit (amount) #:prefab)
|
(struct tcp-credit (amount) #:prefab)
|
||||||
(struct tcp-data (inbound? chunk) #:prefab)
|
(struct tcp-data (chunk) #:prefab)
|
||||||
(struct tcp-eof () #:prefab)
|
(struct tcp-eof () #:prefab)
|
||||||
|
|
||||||
;; The address of a TCP endpoint.
|
;; The address of a TCP endpoint.
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
(loop 0 mode)]
|
(loop 0 mode)]
|
||||||
[else
|
[else
|
||||||
;;(write `(relaying line ,v from ,name)) (newline)
|
;;(write `(relaying line ,v from ,name)) (newline)
|
||||||
(send handle say (topic-publisher name) (tcp-data #t v))
|
(send handle say (topic-publisher name) (tcp-data v))
|
||||||
(loop (- credit 1) mode)])))]
|
(loop (- credit 1) mode)])))]
|
||||||
['bytes (handle-evt (read-bytes-evt credit i)
|
['bytes (handle-evt (read-bytes-evt credit i)
|
||||||
(lambda (v)
|
(lambda (v)
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
(loop 0 mode)]
|
(loop 0 mode)]
|
||||||
[else
|
[else
|
||||||
;;(write `(relaying bytes ,v from ,name)) (newline)
|
;;(write `(relaying bytes ,v from ,name)) (newline)
|
||||||
(send handle say (topic-publisher name) (tcp-data #t v))
|
(send handle say (topic-publisher name) (tcp-data v))
|
||||||
(loop (- credit (bytes-length v)) mode)])))])
|
(loop (- credit (bytes-length v)) mode)])))])
|
||||||
never-evt))))
|
never-evt))))
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
(tcp-abandon-port o)]
|
(tcp-abandon-port o)]
|
||||||
[(says (topic 'publisher (== name) _) (tcp-option 'mode new-mode))
|
[(says (topic 'publisher (== name) _) (tcp-option 'mode new-mode))
|
||||||
(loop new-mode)]
|
(loop new-mode)]
|
||||||
[(says (topic 'publisher (== name) _) (tcp-data #f v))
|
[(says (topic 'publisher (== name) _) (tcp-data v))
|
||||||
;;(write `(writing ,v to ,name)) (newline)
|
;;(write `(writing ,v to ,name)) (newline)
|
||||||
(define credit-amount
|
(define credit-amount
|
||||||
(match mode
|
(match mode
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
(send h assert! (topic-subscriber inbound-stream))
|
(send h assert! (topic-subscriber inbound-stream))
|
||||||
(send h assert! (topic-publisher groupchat))
|
(send h assert! (topic-publisher groupchat))
|
||||||
(send h assert! (topic-subscriber groupchat))
|
(send h assert! (topic-subscriber groupchat))
|
||||||
(define (send-text s) (send h say (topic-publisher outbound-stream) (tcp-data #f s)))
|
(define (send-text s) (send h say (topic-publisher outbound-stream) (tcp-data s)))
|
||||||
(define (issue-credit) (send h say (topic-subscriber inbound-stream) (tcp-credit 1)))
|
(define (issue-credit) (send h say (topic-subscriber inbound-stream) (tcp-credit 1)))
|
||||||
(issue-credit)
|
(issue-credit)
|
||||||
(let loop ((prompt? #t))
|
(let loop ((prompt? #t))
|
||||||
|
@ -26,12 +26,12 @@
|
||||||
(match (send h listen)
|
(match (send h listen)
|
||||||
[(says (topic 'publisher (== inbound-stream) _) (tcp-eof))
|
[(says (topic 'publisher (== inbound-stream) _) (tcp-eof))
|
||||||
(send-text "OK, bye\n")]
|
(send-text "OK, bye\n")]
|
||||||
[(says (topic 'publisher (== inbound-stream) _) (tcp-data #t "quit"))
|
[(says (topic 'publisher (== inbound-stream) _) (tcp-data "quit"))
|
||||||
(issue-credit)
|
(issue-credit)
|
||||||
(quit-proc)
|
(quit-proc)
|
||||||
(send-text "OK, will quit accepting\n")
|
(send-text "OK, will quit accepting\n")
|
||||||
(loop #t)]
|
(loop #t)]
|
||||||
[(says (topic 'publisher (== inbound-stream) _) (tcp-data #t what))
|
[(says (topic 'publisher (== inbound-stream) _) (tcp-data what))
|
||||||
(write `(someone said ,what))
|
(write `(someone said ,what))
|
||||||
(newline)
|
(newline)
|
||||||
(issue-credit)
|
(issue-credit)
|
||||||
|
|
Loading…
Reference in New Issue