diff --git a/Hermes/TODO b/Hermes/TODO index 6bd88b0..8135f57 100644 --- a/Hermes/TODO +++ b/Hermes/TODO @@ -1,15 +1,17 @@ FEATURES 4. message parsable? 5. command parsable? -7. maybe fiddle around with irc library 8. separate main running code from definitions -10. authentication for databases -11. user can ask for no of logged in users. Server has to pars -e +16. plain tcp -> ssl based +17. fix breaks for improper disconnects from clients +18. Add topics after project completion + +GOOD TO HAVE BUT NOT NECESSARY +7. maybe fiddle around with irc library (we leave this for future opl classes) no time got other classes *14. bye message prompt for clients part of session stickiness *15. Session stickiness for clients. Log received comms to a local file. additionally save user details and prompt user to use defaults or create new ones -16. plain tcp -> ssl based -17. fix breaks for improper disconnects from clients -18. Add topics after project completion +10. authentication for databases - to avoid dependencies this is left out +11. user can ask for no of logged in users. - server already reports + diff --git a/Hermes/client.rkt b/Hermes/client.rkt index 96f55b0..3589765 100644 --- a/Hermes/client.rkt +++ b/Hermes/client.rkt @@ -3,6 +3,7 @@ (require "modules/general.rkt") (require math/base) ;; for random number generation ;; TODO clean up string message output and alignment +;; TODO close ports after done ;; i.e. seconds and minutes hours specifically ;; author: Ibrahim Mkusa ;; about: print and read concurrently @@ -40,21 +41,21 @@ (define a (thread (lambda () - (displayln "Starting receiver thread.") + (displayln-safe "Starting receiver thread." error-out-s error-out) (let loop [] (receive-messages in) (sleep 1) (loop))))) (define t (thread (lambda () - (displayln "Starting sender thread.") + (displayln-safe "Starting sender thread." error-out-s error-out) (let loop [] (send-messages username out) (sleep 1) (loop))))) - (displayln "Now waiting for sender thread.") + (displayln-safe "Now waiting for sender thread." error-out-s error-out) (thread-wait t) ;; returns prompt back to drracket - (displayln "Closing client ports.") + (displayln-safe "Closing client ports." error-out-s error-out) (close-input-port in) (close-output-port out)) (custodian-shutdown-all main-client-cust)) @@ -71,11 +72,14 @@ ":" (number->string (date-second date-today)) " | ")) - ;; intelligent read, quits when user types in "quit" + ;; read, quits when user types in "quit" (define input (read-line)) + ; TODO /quit instead of quit (cond ((string=? input "quit") (displayln (string-append date-print username " signing out. See ya!") out) (flush-output out) + (close-output-port error-out) + (close-output-port convs-out) (exit))) (displayln (string-append date-print username ": " input) out) @@ -87,14 +91,14 @@ (define evt (sync/timeout 60 (read-line-evt in))) (cond [(eof-object? evt) - (displayln "Server connection closed.") + (displayln-safe "Server connection closed." error-out-s error-out) (custodian-shutdown-all main-client-cust) ;(exit) ] [(string? evt) - (displayln evt)] ; could time stamp here or to send message + (displayln-safe evt convs-out-s convs-out)] ; could time stamp here or to send message [else - (displayln (string-append "Nothing received from server for 2 minutes."))])) + (displayln-safe (string-append "Nothing received from server for 2 minutes.") convs-out-s convs-out)])) -(displayln "Starting client.") +(displayln-safe "Starting client." error-out-s error-out) (define stop (client 4321))