22 lines
559 B
JavaScript
22 lines
559 B
JavaScript
|
// Simple jamsh test creating and starting hello world agent
|
||
|
|
||
|
function agent(msg) {
|
||
|
this.msg=msg;
|
||
|
this.act = {
|
||
|
init : function () { log('Starting hello '+this.msg) },
|
||
|
wait: function () { log('Sleeping'); sleep(1000) },
|
||
|
end: function () { if (random(1)) throw "test exception"; /* not reached */
|
||
|
log('Terminating');
|
||
|
kill() }
|
||
|
}
|
||
|
this.trans = {
|
||
|
init: wait,
|
||
|
wait: function () { return random(1)?init:end }
|
||
|
}
|
||
|
this.next = init
|
||
|
}
|
||
|
|
||
|
compile(agent)
|
||
|
create('agent','world')
|
||
|
start()
|