2 Commits 17251045eb ... 1bb8cc7cf5

Autore SHA1 Messaggio Data
  epicmorphism 1bb8cc7cf5 handling of command-errors 4 anni fa
  epicmorphism c2659ae51f better and cleaner irc-functions/read-from-client 4 anni fa
2 ha cambiato i file con 10 aggiunte e 2 eliminazioni
  1. 1 0
      chat.rkt
  2. 9 2
      private/irc-functions.rkt

+ 1 - 0
chat.rkt

@@ -62,6 +62,7 @@
                       (match type
                         ['chat (on-chat from (unheck-html message))]
                         ['response (on-response (unheck-all-html message))]
+                        ['command-error (on-response (unheck-all-html message))]
                         [_
                          (log-warning
                           (format "chat.rkt/handl-evt: cannot handle message type in ~s" msg))])]))]

+ 9 - 2
private/irc-functions.rkt

@@ -56,10 +56,17 @@
                          (U irc-message False EOF)))
 (define (read-from-client conn #:timeout [timeout #f])
   (define in-port (irc-connection-in conn))
-  (if (and timeout (not (sync/timeout timeout in-port)))
+  (: rl-evt (Evtof (U EOF String)))
+  (define rl-evt (read-line-evt in-port 'any))
+  (: line (U False EOF String))
+  (define line (if timeout
+                   (sync/timeout timeout rl-evt)
+                   (sync rl-evt)))
+  (if (string? line)
+      (parse-message line)
       ;; if the timeout was triggered
       eof   ;; return eof so that the caller closes teh connection
-      (read-from-input-port in-port)))
+      ))
 
 
 ;; Given the string of an IRC message, returns an irc-message that has been parsed as far as possible,