aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahim Mkusa <ibrahimmkusa@gmail.com>2017-04-16 17:47:42 -0400
committerIbrahim Mkusa <ibrahimmkusa@gmail.com>2017-04-16 17:47:42 -0400
commitf10fb083cda715faba8d5aab40dbcf9ab0d501c1 (patch)
treedaec1c8b527e9fcef7d4965f74133c1bc188a111
parent6680d7504b2b1c45a6cfd0049212e162c279e172 (diff)
broadcast now checks whether port is open before trying to send
-rw-r--r--Hermes/TODO11
-rw-r--r--Hermes/client.rkt6
-rw-r--r--Hermes/server.rkt9
3 files changed, 11 insertions, 15 deletions
diff --git a/Hermes/TODO b/Hermes/TODO
index a1a92df..bbc2930 100644
--- a/Hermes/TODO
+++ b/Hermes/TODO
@@ -1,15 +1,11 @@
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
17. fix breaks for improper disconnects from clients
18. Add topics after project completion
** 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
-** adjust sleep time on all to be 0.1 for more responsiveness
-** better function names
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
@@ -18,7 +14,4 @@ GOOD TO HAVE BUT NOT NECESSARY
additionally save user details and prompt user to use defaults or create
new ones
10. authentication for databases - to avoid dependencies this is left out
-11. user can ask for no of logged in users. - server already reports
-even the list of users connected.
-12. on connection server should also display list of users currently logged in
-** whispers aren't currently logged
+** whispers aren't currently logged - its on purpose
diff --git a/Hermes/client.rkt b/Hermes/client.rkt
index 8959b1c..0e3c986 100644
--- a/Hermes/client.rkt
+++ b/Hermes/client.rkt
@@ -10,8 +10,8 @@
;; notes: output may need to be aligned and formatted nicely
-; i could prompt for these instead
-(define host "10.0.0.160") ; internal home
+; we will prompt for these in the gui
+(define host "10.0.0.160")
(define host2 "67.186.191.81")
(define host3 "localhost")
(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 "Starting client." error-out-s error-out)
-(define stop (client 4321))
+(define stop-client (client 4321))
diff --git a/Hermes/server.rkt b/Hermes/server.rkt
index 5e5f546..df1cf26 100644
--- a/Hermes/server.rkt
+++ b/Hermes/server.rkt
@@ -260,8 +260,11 @@
(cond [(not (null? ((c-messages 'mes-list))))
(begin (map
(lambda (ports)
- (displayln (first ((c-messages 'mes-list))) (get-output-port ports))
- (flush-output (get-output-port ports)))
+ (if (not (port-closed? (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)))
(displayln-safe (first ((c-messages 'mes-list))) convs-out-s convs-out)
;; remove top message
@@ -269,5 +272,5 @@
(displayln "Message broadcasted"))])
(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)