-(import sam
- matchable
+(import matchable
srfi-13
(chicken process-context))
(define (main-beh self system)
(send-message (make-actor (make-client-beh system)) 'start)
'done)
-
-(define (print-usage)
- (print "Actor-driven chat client.\n")
- (print "Usage: chat_client -h")
- (print " chat_client [-p port_num] [-n host_name]"))
-
-(let loop ((args (cdr (argv)))
- (host "localhost")
- (port 8000))
- (match args
- (((or "-h" "--help"))
- (print-usage))
- (((or "-p" "--port") pstr rest ...)
- (loop rest host (string->number pstr)))
- (((or "-n" "--hostname") hstr rest ...)
- (loop rest hstr port))
- (()
- (boot-sam host port main-beh))
- (else
- (print "Unrecognised argument '" (car args) "'.\n")
- (print-usage))))
-
(chicken port)
(chicken process-context)
(chicken file)
+ (chicken condition)
matchable
srfi-18 ; threads
srfi-69 ; hash-table
(define (boot-sam)
(start-console)
(start-network-listener)
- (send-message (make-actor main-beh) (make-actor system-beh))
+ (let ((system (make-actor system-beh))
+ (main #f))
+ (condition-case
+ (begin
+ (set! main (make-actor main-beh)))
+ ((exn)
+ (print "Error starting main actor. Is main-beh defined?")
+ (exit 1)))
+ (send-message main system))
(start-scheduler))
(define (print-usage)
(loop rest))
(((or "-n" "--hostname") hstr rest ...)
(set! sam-host hstr)
- (loop rest)
- (((? file-exists? filename) rest ...))
+ (loop rest))
+ (((? file-exists? filename) rest ...)
(print* "Loading " filename "...")
(load filename)
(print " done.")
(loop rest))
(()
- (boot-sam host port main-beh))
+ (boot-sam))
(else
(print "Unrecognised argument '" (car args) "'.\n")
(print-usage))))
-(import sam
- matchable
+(import matchable
(chicken process-context)
srfi-18)
(send-message system 'print "Hello, what is your name?")
(send-message system 'read
(make-actor (lambda (self . message)
- (print message)
(match message
((name)
(send-message system 'print "Hello, " name "!")
'done)))))
(send-message-later system 10 'print "Boo!"))
-
-(let loop ((args (cdr (argv)))
- (host "localhost")
- (port 8000))
- (match args
- (((or "-h" "--help"))
- (print "Usage: simple_test [ -h ] [ --port PORT ] [ --hostname host ]"))
- (((or "-p" "--port") pstr rest ...)
- (loop rest host (string->number pstr)))
- (("--hostname" hstr rest ...)
- (loop rest hstr port))
- (()
- (print "-- Starting SAM on " host ":" port " --\n")
- (boot-sam host port main-beh))))