<commit_before>(declare (uses client highlevel-io remote user event debug))
(use (srfi 1) posix tcp)
(include "shared/macros.scm")

(define port-number 2000)

(define (login! username password)
  (user-load! username)
  (if (user-password-match? username password)
    (begin (client-username-set! current-client username)
           (hash-table-set! client-name-table username current-client)
           #t)
    (begin (user-unload! username)
           (error "invalid password"))))

(expose! '+ 'anon)
(expose! '- "robert")
(expose! '*)
(expose! '/)
(expose! 'user-add! 'anon)
(expose! 'user-save!)
(expose! 'user-load!)
(expose! 'login! 'anon)
(expose! 'client-find 'anon)

(user-clean-directory!)

(define listener (tcp-listen port-number))
(client-add! listener)

(client-add! (make-client #f (make-chatter fileno/stdin
                                           fileno/stdout
                                           fileno/stderr
                                           sep-scheme-expr
                                           remote-command)))

(event-add! (interval 1) (lambda () (chatter-message! (client-chat (fd-client (car client-read-fds))) "hello")) #t)

(let main-loop ()
  (set! current-client (client-pop!))
  (cond
    [(eqv? current-client #f)
     (events-process!)]
    [(tcp-listener? current-client)
     (if (tcp-accept-ready? current-client)
      (receive (from to) (tcp-accept current-client)
        (client-add! (make-client #f (make-chatter (port->fileno from)
                                                   (port->fileno to)
                                                   (port->fileno to)
                                                   sep-scheme-expr
                                                   remote-command)))))]<commit_msg>Bug fix for chatter-message! test<commit_after>(declare (uses client highlevel-io remote user event debug))
(use (srfi 1) posix tcp)
(include "shared/macros.scm")

(define port-number 2000)

(define (login! username password)
  (user-load! username)
  (if (user-password-match? username password)
    (begin (client-username-set! current-client username)
           (hash-table-set! client-name-table username current-client)
           #t)
    (begin (user-unload! username)
           (error "invalid password"))))

(expose! '+ 'anon)
(expose! '- "robert")
(expose! '*)
(expose! '/)
(expose! 'user-add! 'anon)
(expose! 'user-save!)
(expose! 'user-load!)
(expose! 'login! 'anon)
(expose! 'client-find 'anon)

(user-clean-directory!)

(define listener (tcp-listen port-number))
(client-add! listener)

(client-add! (make-client #f (make-chatter fileno/stdin
                                           fileno/stdout
                                           fileno/stderr
                                           sep-scheme-expr
                                           remote-command)))

(event-add! (interval 1) (lambda ()
                           (for-each (lambda (fd)
                                       (let ([client (fd-client fd)])
                                         (if (not (tcp-listener? client))
                                           (chatter-message! (client-chat client) "hello"))))
                                     client-read-fds)) #t)

(let main-loop ()
  (set! current-client (client-pop!))
  (cond
    [(eqv? current-client #f)
     (events-process!)]
    [(tcp-listener? current-client)
     (if (tcp-accept-ready? current-client)
      (receive (from to) (tcp-accept current-client)
        (client-add! (make-client #f (make-chatter (port->fileno from)
                                                   (port->fileno to)
                                                   (port->fileno to)
                                                   sep-scheme-expr
                                                   remote-command)))))]
{'fraction_non_alphanumeric': 0.134869272586073, 'fraction_numerical': 0.003106393994304944, 'mean_word_length': 1.5538664904163912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 39, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1149822', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1038, 'n_words': 255}