broadcast now checks whether port is open before trying to send

This commit is contained in:
Ibrahim Mkusa 2017-04-16 17:47:42 -04:00
parent 6680d7504b
commit f10fb083cd
3 changed files with 11 additions and 15 deletions

View File

@ -1,15 +1,11 @@
FEATURES FEATURES
5. command(whisper, count, users), message parsable? parse in the client side should do something similar for settings (color, quit) 5. parser in the client side should do something similar (/color, /quit)
16. plain tcp -> ssl based 16. plain tcp -> ssl based
17. fix breaks for improper disconnects from clients 17. fix breaks for improper disconnects from clients
18. Add topics after project completion 18. Add topics after project completion
** regexes to parse strings for different formats -related to 5 ** regexes to parse strings for different formats -related to 5
** put into a list if necessary for manipulation
** sync/timeout to plain sync
** align code better for readability ** align code better for readability
** adjust sleep time on all to be 0.1 for more responsiveness
** better function names
GOOD TO HAVE BUT NOT NECESSARY 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 7. maybe fiddle around with irc library (we leave this for future opl classes) no time got other classes
@ -18,7 +14,4 @@ GOOD TO HAVE BUT NOT NECESSARY
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
10. authentication for databases - to avoid dependencies this is left out 10. authentication for databases - to avoid dependencies this is left out
11. user can ask for no of logged in users. - server already reports ** whispers aren't currently logged - its on purpose
even the list of users connected.
12. on connection server should also display list of users currently logged in
** whispers aren't currently logged

View File

@ -10,8 +10,8 @@
;; notes: output may need to be aligned and formatted nicely ;; notes: output may need to be aligned and formatted nicely
; i could prompt for these instead ; we will prompt for these in the gui
(define host "10.0.0.160") ; internal home (define host "10.0.0.160")
(define host2 "67.186.191.81") (define host2 "67.186.191.81")
(define host3 "localhost") (define host3 "localhost")
(define port-num 4321) (define port-num 4321)
@ -107,4 +107,4 @@
(displayln-safe (string-append "Nothing received from server for 2 minutes.") convs-out-s convs-out)])) (displayln-safe (string-append "Nothing received from server for 2 minutes.") convs-out-s convs-out)]))
(displayln-safe "Starting client." error-out-s error-out) (displayln-safe "Starting client." error-out-s error-out)
(define stop (client 4321)) (define stop-client (client 4321))

View File

@ -260,8 +260,11 @@
(cond [(not (null? ((c-messages 'mes-list)))) (cond [(not (null? ((c-messages 'mes-list))))
(begin (map (begin (map
(lambda (ports) (lambda (ports)
(displayln (first ((c-messages 'mes-list))) (get-output-port ports)) (if (not (port-closed? (get-output-port ports)))
(flush-output (get-output-port ports))) (begin
(displayln (first ((c-messages 'mes-list))) (get-output-port ports))
(flush-output (get-output-port ports)))
(displayln-safe "Failed to broadcast. Port not open." error-out-s error-out)))
((c-connections 'cons-list))) ((c-connections 'cons-list)))
(displayln-safe (first ((c-messages 'mes-list))) convs-out-s convs-out) (displayln-safe (first ((c-messages 'mes-list))) convs-out-s convs-out)
;; remove top message ;; remove top message
@ -269,5 +272,5 @@
(displayln "Message broadcasted"))]) (displayln "Message broadcasted"))])
(semaphore-post messages-s))) (semaphore-post messages-s)))
(define stop (serve 4321)) ;; start server then close with stop (define stop-server (serve 4321)) ;; start server then close with stop
(displayln-safe "Server process started\n" error-out-s error-out) (displayln-safe "Server process started\n" error-out-s error-out)