timestamps added to messages
This commit is contained in:
parent
31308f35fd
commit
f6687e7d62
@ -1,6 +1,5 @@
|
|||||||
1. Create a racket module for commonly used functions
|
1. Create a racket module for commonly used functions
|
||||||
2. Log messages to proper file on server
|
2. Log messages to proper file on server
|
||||||
3. add timestamps to clients messages
|
|
||||||
4. message parsable?
|
4. message parsable?
|
||||||
5. command parsable?
|
5. command parsable?
|
||||||
6. keep count of connected clients using object orientation
|
6. keep count of connected clients using object orientation
|
||||||
@ -10,4 +9,8 @@
|
|||||||
like make-account
|
like make-account
|
||||||
make own count to deal with closures
|
make own count to deal with closures
|
||||||
10. authentication for databases
|
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
|
||||||
|
@ -46,13 +46,21 @@
|
|||||||
;; intelligent read, quits when user types in "quit"
|
;; intelligent read, quits when user types in "quit"
|
||||||
(define input (read-line))
|
(define input (read-line))
|
||||||
(cond ((string=? input "quit") (exit)))
|
(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))
|
(flush-output out))
|
||||||
|
|
||||||
; receives input from server and displays it to stdout
|
; receives input from server and displays it to stdout
|
||||||
(define (receive-messages in)
|
(define (receive-messages in)
|
||||||
; retrieve a message from server
|
; retrieve a message from server
|
||||||
(define evt (sync/timeout 60 (read-line-evt in)))
|
(define evt (sync/timeout 60 (read-line-evt in)))
|
||||||
|
|
||||||
(cond [(eof-object? evt)
|
(cond [(eof-object? evt)
|
||||||
(displayln "Server connection closed.")
|
(displayln "Server connection closed.")
|
||||||
(custodian-shutdown-all main-client-cust)
|
(custodian-shutdown-all main-client-cust)
|
||||||
|
@ -107,7 +107,6 @@
|
|||||||
(displayln welcome-message out)
|
(displayln welcome-message out)
|
||||||
(flush-output out)
|
(flush-output out)
|
||||||
(semaphore-wait connections-s)
|
(semaphore-wait connections-s)
|
||||||
; (set! connections (append connections (list (list in out))))
|
|
||||||
((c-connections 'add) in out)
|
((c-connections 'add) in out)
|
||||||
(semaphore-post connections-s)
|
(semaphore-post connections-s)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user