7 (lambda (self . message)
13 (send-message system 'print "Welcome to chat!\n"
14 "Your client address is " (address->string self) ".\n"
15 "Type '/help' for a list of commands.\n")
16 (send-message system 'read self))
17 (('show-msg from text)
18 (send-message system 'print "Message from " from ": " text))
20 (if (string-prefix? "/" str)
21 (let* ((idx (string-index str #\space))
22 (cmd (substring str 1 idx))
23 (arg (substring str idx)))
26 (send-message system 'print
27 "Command | Description\n"
28 "------------------------------\n"
29 "\help List commands\n"
30 "\join <address> Join chat with specified client\n"
33 (set! recipients (cons (uri-reference arg) recipients))
34 (send-message system 'print "Added recipient to chat."))
36 (send-message system 'exit))
38 (send-message system 'print "Unrecognised command '" cmd "'"))))
39 (let loop (recipients-left recipients)
40 (unless (null? recipients-left)
41 (send-message (car recipients-left) 'show-msg name str)
42 (loop (cdr recipients-left)))))))
43 (send-message system 'read self)
48 (let loop ((args (cdr (argv)))
54 (((or "-p" "--port") pstr rest ...)
55 (loop rest host (string->number pstr)))
56 (("--hostname" hstr rest ...)
57 (loop rest hstr port))
60 (send-message client 'start)))))