all output generated from client is now logged to appropriate _client

files
This commit is contained in:
Ibrahim Mkusa 2017-04-15 21:53:49 -04:00
parent 63c4e2e185
commit a532a8cc71
2 changed files with 22 additions and 16 deletions

View File

@ -1,15 +1,17 @@
FEATURES FEATURES
4. message parsable? 4. message parsable?
5. command parsable? 5. command parsable?
7. maybe fiddle around with irc library
8. separate main running code from definitions 8. separate main running code from definitions
10. authentication for databases 16. plain tcp -> ssl based
11. user can ask for no of logged in users. Server has to pars 17. fix breaks for improper disconnects from clients
e 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 *14. bye message prompt for clients part of session stickiness
*15. Session stickiness for clients. Log received comms to a local file. *15. Session stickiness for clients. Log received comms to a local file.
additionally save user details and prompt user to use defaults or create additionally save user details and prompt user to use defaults or create
new ones new ones
16. plain tcp -> ssl based 10. authentication for databases - to avoid dependencies this is left out
17. fix breaks for improper disconnects from clients 11. user can ask for no of logged in users. - server already reports
18. Add topics after project completion

View File

@ -3,6 +3,7 @@
(require "modules/general.rkt") (require "modules/general.rkt")
(require math/base) ;; for random number generation (require math/base) ;; for random number generation
;; TODO clean up string message output and alignment ;; TODO clean up string message output and alignment
;; TODO close ports after done
;; i.e. seconds and minutes hours specifically ;; i.e. seconds and minutes hours specifically
;; author: Ibrahim Mkusa ;; author: Ibrahim Mkusa
;; about: print and read concurrently ;; about: print and read concurrently
@ -40,21 +41,21 @@
(define a (thread (define a (thread
(lambda () (lambda ()
(displayln "Starting receiver thread.") (displayln-safe "Starting receiver thread." error-out-s error-out)
(let loop [] (let loop []
(receive-messages in) (receive-messages in)
(sleep 1) (sleep 1)
(loop))))) (loop)))))
(define t (thread (define t (thread
(lambda () (lambda ()
(displayln "Starting sender thread.") (displayln-safe "Starting sender thread." error-out-s error-out)
(let loop [] (let loop []
(send-messages username out) (send-messages username out)
(sleep 1) (sleep 1)
(loop))))) (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 (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-input-port in)
(close-output-port out)) (close-output-port out))
(custodian-shutdown-all main-client-cust)) (custodian-shutdown-all main-client-cust))
@ -71,11 +72,14 @@
":" ":"
(number->string (date-second date-today)) (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)) (define input (read-line))
; TODO /quit instead of quit
(cond ((string=? input "quit") (cond ((string=? input "quit")
(displayln (string-append date-print username " signing out. See ya!") out) (displayln (string-append date-print username " signing out. See ya!") out)
(flush-output out) (flush-output out)
(close-output-port error-out)
(close-output-port convs-out)
(exit))) (exit)))
(displayln (string-append date-print username ": " input) out) (displayln (string-append date-print username ": " input) out)
@ -87,14 +91,14 @@
(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-safe "Server connection closed." error-out-s error-out)
(custodian-shutdown-all main-client-cust) (custodian-shutdown-all main-client-cust)
;(exit) ;(exit)
] ]
[(string? evt) [(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 [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)) (define stop (client 4321))