timestamps added to messages

This commit is contained in:
Ibrahim Mkusa 2017-04-13 15:20:47 -04:00
parent 31308f35fd
commit f6687e7d62
3 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)