refactor(settings): utilize callbacks to resolve todo item
Signed-off-by: zontreck <tarapiccari@gmail.com>
This commit is contained in:
parent
5a333f262f
commit
451530b054
1 changed files with 18 additions and 8 deletions
|
@ -43,8 +43,7 @@ NoSetting(string sKey) {
|
|||
default
|
||||
{
|
||||
state_entry() {
|
||||
llSetTimerEvent(5); // TODO: Change this to schedule with the TaskScheduler module for a callback
|
||||
// After expiration of timer, send all settings
|
||||
LM(LINK_SIGNAL_CALLBACKS, OP_CALLBACK_CHK_STATUS, EMPTY_JSON);
|
||||
}
|
||||
|
||||
changed(integer iChange) {
|
||||
|
@ -54,12 +53,6 @@ default
|
|||
}
|
||||
}
|
||||
|
||||
timer() {
|
||||
llSetTimerEvent(0);
|
||||
|
||||
reqAllSettings();
|
||||
}
|
||||
|
||||
link_message(integer iSender, integer iNum, string sMsg, key kID)
|
||||
{
|
||||
DEBUG_FUNC(true, "link_message", [iNum, sMsg, kID]);
|
||||
|
@ -84,6 +77,23 @@ default
|
|||
DEBUG_FUNC(true, "LINK_SIGNAL_REBOOT", []);
|
||||
DEBUG_FUNC(false, "LINK_SIGNAL_REBOOT", []);
|
||||
llResetScript();
|
||||
} else if(iNum == LINK_SIGNAL_CALLBACKS) {
|
||||
string sOp = llJsonGetValue(sMsg, ["op"]);
|
||||
switch(sOp) {
|
||||
case OP_CALLBACK_READY: {
|
||||
// Schedule callback to load all settings
|
||||
ScheduleCallback("settings_start", 10, llGetScriptName());
|
||||
break;
|
||||
}
|
||||
case OP_CALLBACK: {
|
||||
if(llJsonGetValue(sMsg, ["target"]) == llGetScriptName()) {
|
||||
if(llJsonGetValue(sMsg, ["id"]) == "settings_start") {
|
||||
reqAllSettings();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DEBUG_FUNC(false, "link_message", []);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue