aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Hermes/TODO1
-rw-r--r--Hermes/client.rkt3
-rw-r--r--Hermes/server.rkt15
3 files changed, 11 insertions, 8 deletions
diff --git a/Hermes/TODO b/Hermes/TODO
index 7a192c8..9243681 100644
--- a/Hermes/TODO
+++ b/Hermes/TODO
@@ -1,7 +1,6 @@
FEATURES
need to pass color settings between users
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
** align code better for readability
diff --git a/Hermes/client.rkt b/Hermes/client.rkt
index 2efa13f..67b02c3 100644
--- a/Hermes/client.rkt
+++ b/Hermes/client.rkt
@@ -129,7 +129,8 @@
(cond [(eof-object? evt)
(displayln-safe "Server connection closed." error-out-s error-out)
- (custodian-shutdown-all main-client-cust)
+ (exit)
+ ;(custodian-shutdown-all main-client-cust)
;(exit)
]
[(string? evt)
diff --git a/Hermes/server.rkt b/Hermes/server.rkt
index d43f180..b7e928f 100644
--- a/Hermes/server.rkt
+++ b/Hermes/server.rkt
@@ -188,26 +188,29 @@
(define list-count (regexp-match #px"(.*)/list\\s+count\\s*" evt-t0)) ;; is client asking for number of logged in users
(define list-users (regexp-match #px"(.*)/list\\s+users\\s*" evt-t0)) ;; user names
; do something whether it was a message, a whisper, request for number of users and so on
+
; TODO if user doesn't exist handle it********
(cond [whisper
(semaphore-wait connections-s)
; get output port for user
+ ; this might be null
(define that-user-ports
- (first (filter
+ (filter
(lambda (ports)
(if (string=? (whisper-to whisper) (get-username ports))
#t
#f))
- ((c-connections 'cons-list)))))
+ ((c-connections 'cons-list))))
; try to send that user the whisper
- (if (port-closed? (get-output-port that-user-ports))
+ (if (and (null? that-user-ports)
+ #t) ; #t is placeholder for further checks
(begin
- (displayln "User is unavailable" out)
+ (displayln "User is unavailable. /color black" out)
(flush-output out))
(begin
(displayln (string-append (whisper-info whisper) (whisper-message whisper))
- (get-output-port that-user-ports))
- (flush-output (get-output-port that-user-ports))))
+ (get-output-port (car that-user-ports)))
+ (flush-output (get-output-port (car that-user-ports)))))
(semaphore-post connections-s)]
[list-count
;;should put a semaphore on connections