Use tcp-in-line in chat-tcp2.rkt

This commit is contained in:
Tony Garnock-Jones 2017-10-21 14:54:53 +01:00
parent fa82634868
commit 8999b8446d
1 changed files with 2 additions and 3 deletions

View File

@ -3,7 +3,6 @@
;; driver split out into syndicate/drivers/tcp2.
(require/activate syndicate/drivers/tcp2)
(require (only-in racket/string string-trim))
(require racket/format)
(message-struct speak (who what))
@ -14,8 +13,8 @@
(assert (tcp-accepted id))
(let ((me (gensym 'user)))
(assert (present me))
(on (message (tcp-in id $bs))
(send! (speak me (string-trim (bytes->string/utf-8 bs))))))
(on (message (tcp-in-line id $bs))
(send! (speak me (bytes->string/utf-8 bs)))))
(during (present $user)
(on-start (send! (tcp-out id (string->bytes/utf-8 (~a user " arrived\n")))))
(on-stop (send! (tcp-out id (string->bytes/utf-8 (~a user " left\n")))))