Created
March 10, 2019 03:16
-
-
Save LaxLacks/a5b5807dce053cb92b0b79f495293108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objectdef unicasttest_Controller | |
{ | |
variable taskmanager TaskManager=${LMAC.NewTaskManager["unicasttest"]} | |
method Initialize() | |
{ | |
; echo TaskManager.ID=${TaskManager.ID} | |
} | |
method Shutdown() | |
{ | |
LMAC.TaskManager["unicasttest"]:Destroy | |
} | |
method LocalHelloWorld() | |
{ | |
; initialize a new JSON object | |
variable jsonvalue MyTask={} | |
; set a value called "type" to a JSON string containing ls1.echo. The inner (escaped) quotes are for the JSON parser to identify the value as a string. | |
MyTask:Set["type","\"ls1.echo\""] | |
MyTask:Set["output","\"Hello World! (local)\""] | |
; echo TaskManager:BeginTask["${MyTask.AsJSON.Escape[0].Escape}"] | |
; outputs .... | |
; TaskManager:BeginTask["{\"output\":\"Hello World! (local)\",\"type\":\"ls1.echo\"}"] | |
; use our dynamic JSON object... | |
TaskManager:BeginTask["${MyTask.AsJSON.Escape[0]}"] | |
} | |
method UnicastEcho(string _target, string _output) | |
{ | |
; initialize a new JSON object | |
variable jsonvalue MyTask={} | |
variable jsonvalue InnerTask={} | |
InnerTask:Set["type","\"ls1.echo\""] | |
InnerTask:Set["output","\"${_output.Escape}\""] | |
MyTask:Set["type","\"unicast\""] | |
MyTask:Set["target","\"${_target.Escape}\""] | |
MyTask:Set["task","${InnerTask.AsJSON.Escape[0]}"] | |
; echo TaskManager:BeginTask["${MyTask.AsJSON.Escape[0].Escape}"] | |
; outputs for example ... | |
; TaskManager:BeginTask["{\"target\":\"is1\",\"task\":{\"output\":\"Hello World! (From uplink)\",\"type\":\"ls1.echo\"},\"type\":\"unicast\"}"] | |
; use our dynamic JSON object... | |
TaskManager:BeginTask["${MyTask.AsJSON.Escape[0]}"] | |
} | |
method Start() | |
{ | |
This:LocalHelloWorld | |
if ${Session(exists)} | |
This:UnicastEcho["is1","Hello World! (From ${Session})"] | |
else | |
This:UnicastEcho["is1","Hello World! (From uplink)"] | |
; TaskManager:BeginTask["{\"target\":\"is1\",\"task\":{\"output\":\"Hello world!\",\"type\":\"ls1.echo\"},\"type\":\"unicast\"}"] | |
} | |
} | |
variable(global) unicasttest_Controller UnicastTest | |
function main() | |
{ | |
UnicastTest:Start | |
while 1 | |
{ | |
waitframe | |
} | |
} | |
atom atexit() | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment