diff options
-rw-r--r-- | Hermes/TODO | 7 | ||||
-rw-r--r-- | Hermes/client.rkt | 10 | ||||
-rw-r--r-- | Hermes/server.rkt | 1 |
3 files changed, 14 insertions, 4 deletions
diff --git a/Hermes/TODO b/Hermes/TODO index c1f17fa..5a357fc 100644 --- a/Hermes/TODO +++ b/Hermes/TODO @@ -1,6 +1,5 @@ 1. Create a racket module for commonly used functions 2. Log messages to proper file on server -3. add timestamps to clients messages 4. message parsable? 5. command parsable? 6. keep count of connected clients using object orientation @@ -10,4 +9,8 @@ like make-account make own count to deal with closures 10. authentication for databases -11. user can ask for no of logged in users. Server has to parse +11. user can ask for no of logged in users. Server has to pars +e +12. Hide user's own input in command line +13. Need to gracefully handle disconnected clients by removing from list +of connections diff --git a/Hermes/client.rkt b/Hermes/client.rkt index 11e2041..86813ac 100644 --- a/Hermes/client.rkt +++ b/Hermes/client.rkt @@ -46,13 +46,21 @@ ;; intelligent read, quits when user types in "quit" (define input (read-line)) (cond ((string=? input "quit") (exit))) - (displayln (string-append username ": " input) out) + ; get current time + (define date-today (seconds->date (current-seconds) #t)) + ;TODO pad the second if its only 1 character + (define date-print (string-append (number->string (date-hour date-today)) + ":" + (number->string (date-second date-today)) + "| ")) + (displayln (string-append date-print username ": " input) out) (flush-output out)) ; receives input from server and displays it to stdout (define (receive-messages in) ; retrieve a message from server (define evt (sync/timeout 60 (read-line-evt in))) + (cond [(eof-object? evt) (displayln "Server connection closed.") (custodian-shutdown-all main-client-cust) diff --git a/Hermes/server.rkt b/Hermes/server.rkt index a672c2b..20a83bb 100644 --- a/Hermes/server.rkt +++ b/Hermes/server.rkt @@ -107,7 +107,6 @@ (displayln welcome-message out) (flush-output out) (semaphore-wait connections-s) - ; (set! connections (append connections (list (list in out)))) ((c-connections 'add) in out) (semaphore-post connections-s) |