clients can type /list users to get usernames logged in
This commit is contained in:
parent
ec7b9a644a
commit
9e1f8c33d1
@ -1,3 +1,3 @@
|
|||||||
# Remove idiotic save files
|
# Remove temporary files
|
||||||
clean:
|
clean:
|
||||||
rm -rf *~
|
rm -rf *~ *.out
|
||||||
|
@ -179,7 +179,7 @@
|
|||||||
; use regexes to evaluate received input from client
|
; use regexes to evaluate received input from client
|
||||||
(define whisper (regexp-match #px"(.*)/whisper\\s+(\\w+)\\s+(.*)" evt-t0)) ; is client trying to whisper to someone
|
(define whisper (regexp-match #px"(.*)/whisper\\s+(\\w+)\\s+(.*)" evt-t0)) ; is client trying to whisper to someone
|
||||||
(define list-count (regexp-match #px"(.*)/list\\s+count\\s*" evt-t0)) ;; is client asking for number of logged in users
|
(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
|
(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
|
; do something whether it was a message, a whisper, request for number of users and so on
|
||||||
(cond [whisper
|
(cond [whisper
|
||||||
(semaphore-wait connections-s)
|
(semaphore-wait connections-s)
|
||||||
@ -212,6 +212,16 @@
|
|||||||
(semaphore-post connections-s)
|
(semaphore-post connections-s)
|
||||||
(semaphore-post c-count-s)
|
(semaphore-post c-count-s)
|
||||||
]
|
]
|
||||||
|
[list-users
|
||||||
|
(semaphore-wait connections-s)
|
||||||
|
; map over connections sending the username to the client
|
||||||
|
(displayln "Here is a list of users in chat." out)
|
||||||
|
(map
|
||||||
|
(lambda (ports)
|
||||||
|
(displayln (get-username ports) out))
|
||||||
|
((c-connections 'cons-list)))
|
||||||
|
(flush-output out)
|
||||||
|
(semaphore-post connections-s)]
|
||||||
[else
|
[else
|
||||||
(displayln-safe evt-t0)
|
(displayln-safe evt-t0)
|
||||||
(semaphore-wait messages-s)
|
(semaphore-wait messages-s)
|
||||||
|
Loading…
Reference in New Issue
Block a user