Entersenate chat-sync.rkt
This commit is contained in:
parent
8f897119a9
commit
732010a40a
|
@ -22,18 +22,14 @@
|
|||
(let loop ()
|
||||
(sync (wrap-evt (read-bytes-line-evt cin 'any)
|
||||
(lambda (line)
|
||||
(if (eof-object? line)
|
||||
'done
|
||||
(begin
|
||||
(call-with-semaphore active-connection-mutex
|
||||
(lambda ()
|
||||
(for ([c active-connections])
|
||||
(thread-send (car c) `(says ,connection-id ,line)))))
|
||||
(loop)))))
|
||||
(cond [(eof-object? line) 'done]
|
||||
[else
|
||||
(for ([c active-connections])
|
||||
(thread-send (car c) `(says ,connection-id ,line)))
|
||||
(loop)])))
|
||||
(wrap-evt (thread-receive-evt)
|
||||
(lambda (dummy)
|
||||
(define message (thread-receive))
|
||||
(write message cout)
|
||||
(write (thread-receive) cout)
|
||||
(newline cout)
|
||||
(flush-output cout)
|
||||
(loop)))))
|
||||
|
|
Loading…
Reference in New Issue