}
}
- return daemonServe(ctx, listener, telegram, func(notify func(Event)) (*loop, error) {
- return newLoop(agent, memory, client, time.Now, notify)
+ return daemonServe(ctx, listener, telegram, func(notify func(Event)) (*TurnLoop, error) {
+ return newTurnLoop(agent, memory, client, time.Now, notify)
})
}
// Accept serves each client of listener until the listener closes. A new
// client gets a ready event with the name of the agent, and a busy event when a
// turn runs.
-func (h *DaemonHub) Accept(ctx context.Context, listener net.Listener, l *loop) {
+func (h *DaemonHub) Accept(ctx context.Context, listener net.Listener, l *TurnLoop) {
for {
conn, err := listener.Accept()
if err != nil {
}
// read runs the requests of client until it closes its connection.
-func (h *DaemonHub) read(ctx context.Context, client *DaemonClient, l *loop) {
+func (h *DaemonHub) read(ctx context.Context, client *DaemonClient, l *TurnLoop) {
defer h.workers.Done()
defer h.drop(client)
// daemonServe runs the loop that start makes and serves the clients of listener
// until ctx ends or the loop fails. It closes listener. When bot is not nil, it
// runs the bot too, and a failure of the bot stops the agent.
-func daemonServe(ctx context.Context, listener net.Listener, bot *TelegramBot, start func(notify func(Event)) (*loop, error)) error {
+func daemonServe(ctx context.Context, listener net.Listener, bot *TelegramBot, start func(notify func(Event)) (*TurnLoop, error)) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
}
// daemonRunRequest runs one request of a client.
-func daemonRunRequest(l *loop, request SocketRequest) error {
+func daemonRunRequest(l *TurnLoop, request SocketRequest) error {
switch request.Type {
case "send":
if request.Text == "" {