* 8sync/repl.scm (<repl-manager>):
* 8sync/systems/irc.scm (<irc-bot>): Switch from an 'init action to the
implicit '*init* action.
* 8sync/systems/irc.scm (<irc-bot>, irc-bot-cleanup): Add *cleanup*
handler.
* demos/ircbot.scm:
* doc/8sync-new-manual.org: Drop some calls to 'init when
bootstrapping-messages since we now use '*init*.
;; @@: Should we add a stop action?
#:init-value (build-actions
(*cleanup* repl-manager-cleanup)
;; @@: Should we add a stop action?
#:init-value (build-actions
(*cleanup* repl-manager-cleanup)
- (init repl-manager-init))))
+ (*init* repl-manager-init))))
(define (repl-manager-cleanup repl-manager message)
;; Close the socket, if open
(define (repl-manager-cleanup repl-manager message)
;; Close the socket, if open
(while (actor-alive? repl-manager)
(poll-coop-repl-server server)
(8sleep (repl-manager-poll-every repl-manager))))
(while (actor-alive? repl-manager)
(poll-coop-repl-server server)
(8sleep (repl-manager-poll-every repl-manager))))
(socket #:accessor irc-bot-socket)
(actions #:allocation #:each-subclass
#:init-value (build-actions
(socket #:accessor irc-bot-socket)
(actions #:allocation #:each-subclass
#:init-value (build-actions
+ (*init* irc-bot-init)
+ (*cleanup* irc-bot-cleanup)
(main-loop irc-bot-main-loop)
(send-line irc-bot-send-line-action))))
(main-loop irc-bot-main-loop)
(send-line irc-bot-send-line-action))))
(<- (actor-id irc-bot) 'main-loop))
(<- (actor-id irc-bot) 'main-loop))
+(define (irc-bot-cleanup irc-bot message)
+ (close (irc-bot-socket irc-bot)))
+
(define (irc-bot-main-loop irc-bot message)
(define socket (irc-bot-socket irc-bot))
(define line (string-trim-right (read-line socket) #\return))
(define (irc-bot-main-loop irc-bot message)
(define socket (irc-bot-socket irc-bot))
(define line (string-trim-right (read-line socket) #\return))
(repl
(bootstrap-actor* hive <repl-manager> "repl"))))
(repl
(bootstrap-actor* hive <repl-manager> "repl"))))
- (define initial-messages
- (if repl
- (list (bootstrap-message hive irc-bot 'init)
- (bootstrap-message hive repl-manager 'init))
- (list (bootstrap-message hive irc-bot 'init))))
-
- (run-hive hive initial-messages))
(define (main args)
(define parsed-args (parse-args "ircbot.scm" args))
(define (main args)
(define parsed-args (parse-args "ircbot.scm" args))
#:username username
#:server server
#:channels channels))
#:username username
#:server server
#:channels channels))
- (run-hive hive (list (bootstrap-message hive irc-bot 'init))))
#+END_SRC
Actors are connected to something called a "hive", which is a
#+END_SRC
Actors are connected to something called a "hive", which is a
(bootstrap-actor* hive <repl-manager> "repl"
#:path repl-path))
(bootstrap-actor* hive <repl-manager> "repl"
#:path repl-path))
- (run-hive hive (list (bootstrap-message hive irc-bot 'init)
- (bootstrap-message hive repl-manager 'init))))
#+END_SRC
If we put a call to run-bot at the bottom of our file we can call it,
#+END_SRC
If we put a call to run-bot at the bottom of our file we can call it,