From 56a40ee894d213f10b9c413675170281b8d37056 Mon Sep 17 00:00:00 2001 From: narawat lamaiin Date: Wed, 20 Mar 2024 15:02:19 +0700 Subject: [PATCH] update --- src/type.jl | 4 ++-- src/utils.jl | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/type.jl b/src/type.jl index 13ea2f8..a549397 100644 --- a/src/type.jl +++ b/src/type.jl @@ -212,8 +212,8 @@ function agentReflex( maxUserMsg::Int=10, ) - #NEXTVERSION publish to agentConfigTopic to get a config. - #NEXTVERSION get a config message in a.mqttMsgList + #NEXTVERSION publish to a.config[:configtopic] to get a config. + #NEXTVERSION get a config message in a.mqttMsg_internal #NEXTVERSION set agent according to config newAgent = agentReflex( diff --git a/src/utils.jl b/src/utils.jl index 50f2684..e363e9a 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -98,9 +98,9 @@ function sendReceivePrompt(a::T1, prompt::String, sendtopic::String; while true #WORKING check how to receive msg , should i use :text or :message? timepass = (Dates.now() - starttime).value / 1000.0 if isready(a.mqttMsg_internal) - topic, payload = take!(payloadChannel) - if payload[:msgMeta][:repondToMsgId] == outgoing_msg[:msgMeta][:msgId] - result = haskey(payload, :txt) ? payload[:txt] : nothing + topic, payload = take!(a.mqttMsg_internal) + if payload[:msgMeta][:replyToMsgId] == outgoing_msg[:msgMeta][:msgId] + result = haskey(payload, :text) ? payload[:text] : nothing break end elseif timepass <= timeout @@ -112,8 +112,9 @@ function sendReceivePrompt(a::T1, prompt::String, sendtopic::String; else error("undefined condition. timepass=$timepass timeout=$timeout $(@__LINE__)") end + sleep(0.1) # allow other threads to run end - sleep(0.1) # allow other threads to run + return result end