Clients now default to leaving sign out messages

This commit is contained in:
Ibrahim Mkusa 2017-04-13 15:57:58 -04:00
parent f6687e7d62
commit 8d9765ca8c
3 changed files with 17 additions and 8 deletions

View File

@ -5,12 +5,10 @@
6. keep count of connected clients using object orientation
7. maybe fiddle around with irc library
8. separate main running code from definitions
**9. closure connections, messages, threads. Avoid using set! without an object
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 pars
e
12. Hide user's own input in command line
13. Need to gracefully handle disconnected clients by removing from list
** 13. Need to gracefully handle disconnected clients by removing from list
of connections
14. bye message prompt for clients

View File

@ -43,16 +43,22 @@
;; sends a message to the server
(define (send-messages username out)
;; intelligent read, quits when user types in "quit"
(define input (read-line))
(cond ((string=? input "quit") (exit)))
; 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-minute date-today))
":"
(number->string (date-second date-today))
"| "))
" | "))
;; intelligent read, quits when user types in "quit"
(define input (read-line))
(cond ((string=? input "quit")
(displayln (string-append date-print username " signing out. See ya!") out)
(flush-output out)
(exit)))
(displayln (string-append date-print username ": " input) out)
(flush-output out))

View File

@ -105,6 +105,11 @@
"Sending client a welcome message.")
stdout)
(displayln welcome-message out)
;; print to server log and client
(define print-no-users (string-append "Number of users in chat: "
(number->string ((c-count 'current-count)))))
(displayln print-no-users out)
(displayln-safe print-no-users stdout)
(flush-output out)
(semaphore-wait connections-s)
((c-connections 'add) in out)