From 7e7edb4a54d18d7ee75a228b7f2209d99827449f Mon Sep 17 00:00:00 2001 From: Ibrahim Mkusa Date: Sun, 16 Apr 2017 17:20:17 -0400 Subject: [PATCH] sleep delay interval setting now managed as a global variable --- Hermes/client.rkt | 5 +++-- Hermes/server.rkt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Hermes/client.rkt b/Hermes/client.rkt index c328095..e50a37f 100644 --- a/Hermes/client.rkt +++ b/Hermes/client.rkt @@ -15,6 +15,7 @@ (define host2 "67.186.191.81") (define host3 "localhost") (define port-num 4321) +(define sleep-t 0.1) ; we won't need this. Just me being overzealous (define hermes-conf (open-output-file "./hermes_client.conf" #:exists'append)) @@ -49,14 +50,14 @@ (displayln-safe "Starting receiver thread." error-out-s error-out) (let loop [] (receive-messages in) - (sleep 1) + (sleep sleep-t) (loop))))) (define t (thread (lambda () (displayln-safe "Starting sender thread." error-out-s error-out) (let loop [] (send-messages username out) - (sleep 1) + (sleep sleep-t) (loop))))) (displayln-safe "Now waiting for sender thread." error-out-s error-out) (thread-wait t) ;; returns prompt back to drracket diff --git a/Hermes/server.rkt b/Hermes/server.rkt index 6314f3b..ee949f5 100644 --- a/Hermes/server.rkt +++ b/Hermes/server.rkt @@ -4,10 +4,11 @@ (require math/base) ;; for random number generation -;; globals (define welcome-message "Welcome to Hermes coms. Type your message below") (define successful-connection-m "Successfully connected to a client. Sending client a welcome message.") +(define sleep-t 0.1) + ; track number of connections with closure (define (make-count no-count) (define (increment) @@ -95,7 +96,7 @@ (thread (lambda () (displayln-safe "Broadcast thread started!\n") (let loopb [] - (sleep 0.5) ;; wait 0.5 secs before beginning to broadcast + (sleep sleep-t) ;; wait 0.5 secs before beginning to broadcast (broadcast) (loopb))))) (lambda ()