actor detection
Some checks failed
Build and Deploy / build-linux (push) Failing after 1m42s
Build and Deploy / build-windows (CLANG64) (push) Failing after 8m47s
Build and Deploy / package-dist (push) Has been skipped
Build and Deploy / deploy-itch (push) Has been skipped
Build and Deploy / deploy-gitea (push) Has been skipped
Some checks failed
Build and Deploy / build-linux (push) Failing after 1m42s
Build and Deploy / build-windows (CLANG64) (push) Failing after 8m47s
Build and Deploy / package-dist (push) Has been skipped
Build and Deploy / deploy-itch (push) Has been skipped
Build and Deploy / deploy-gitea (push) Has been skipped
This commit is contained in:
@@ -134,7 +134,7 @@ deps += dependency('soloud', static:true)
|
|||||||
|
|
||||||
#deps += dependency('qjs-chipmunk', static:false)
|
#deps += dependency('qjs-chipmunk', static:false)
|
||||||
|
|
||||||
deps += dependency('libqrencode', static: false)
|
deps += dependency('libqrencode', static: true)
|
||||||
|
|
||||||
sources = []
|
sources = []
|
||||||
src += ['anim.c', 'config.c', 'datastream.c','font.c','HandmadeMath.c','jsffi.c','model.c','render.c','script.c','simplex.c','spline.c', 'timer.c', 'transform.c','prosperon.c', 'wildmatch.c', 'sprite.c', 'rtree.c', 'qjs_dmon.c', 'qjs_nota.c', 'qjs_enet.c', 'qjs_soloud.c', 'qjs_qr.c', 'qjs_wota.c']
|
src += ['anim.c', 'config.c', 'datastream.c','font.c','HandmadeMath.c','jsffi.c','model.c','render.c','script.c','simplex.c','spline.c', 'timer.c', 'transform.c','prosperon.c', 'wildmatch.c', 'sprite.c', 'rtree.c', 'qjs_dmon.c', 'qjs_nota.c', 'qjs_enet.c', 'qjs_soloud.c', 'qjs_qr.c', 'qjs_wota.c']
|
||||||
|
|||||||
@@ -520,6 +520,7 @@ script = `(function ${fnname}() { ${script}; })`
|
|||||||
js.eval(DOCPATH, script)()
|
js.eval(DOCPATH, script)()
|
||||||
|
|
||||||
var enet = use('enet')
|
var enet = use('enet')
|
||||||
|
var util = use('util')
|
||||||
|
|
||||||
var $_ = {}
|
var $_ = {}
|
||||||
|
|
||||||
@@ -554,14 +555,23 @@ $_.receiver = function(fn)
|
|||||||
receive_fn = fn;
|
receive_fn = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var underlings = {}
|
||||||
|
|
||||||
$_.start = function(cb, prg, arg)
|
$_.start = function(cb, prg, arg)
|
||||||
{
|
{
|
||||||
|
var guid = util.guid()
|
||||||
|
underlings[guid] = cb
|
||||||
|
os.createprocess(["./prosperon", "spawn", "--program", prg, "--overling", $_.host.port(), "--guid", guid])
|
||||||
}
|
}
|
||||||
|
|
||||||
$_.stop = function(actor)
|
$_.stop = function(actor)
|
||||||
{
|
{
|
||||||
if (!actor)
|
if (!actor)
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
|
|
||||||
|
actor.peer.send({
|
||||||
|
type:"stop",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$_.unneeded = function(fn, seconds)
|
$_.unneeded = function(fn, seconds)
|
||||||
@@ -577,4 +587,44 @@ $_.delay = function(fn, seconds)
|
|||||||
|
|
||||||
use('cmd')(prosperon.argv)
|
use('cmd')(prosperon.argv)
|
||||||
|
|
||||||
|
function handle_receive(e)
|
||||||
|
{
|
||||||
|
var data = e.data
|
||||||
|
switch(data.type) {
|
||||||
|
case "greet":
|
||||||
|
if (underlings[data.guid]) underlings[data.guid]({
|
||||||
|
type: "greet",
|
||||||
|
data: {peer:e.peer}
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case "stop":
|
||||||
|
console.log("STOPPING!")
|
||||||
|
os.exit(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var hang = 0.016
|
||||||
|
while (1) {
|
||||||
|
os.waitevent(_ => {}, hang)
|
||||||
|
host.service(e => {
|
||||||
|
switch(e.type) {
|
||||||
|
case "connect":
|
||||||
|
console.log(`connected. sending greet with guid ${prosperon.guid} to peer ${e.peer}`)
|
||||||
|
e.peer.send({
|
||||||
|
type: "greet",
|
||||||
|
guid: prosperon.guid
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "receive":
|
||||||
|
handle_receive(e);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "disconnect":
|
||||||
|
console.log(`this peer left: ${e.peer}`)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}, hang);
|
||||||
|
}
|
||||||
|
|
||||||
})()
|
})()
|
||||||
|
|||||||
@@ -189,18 +189,13 @@ Cmdline.register_order(
|
|||||||
console.log(json.encode(args));
|
console.log(json.encode(args));
|
||||||
if (!args.program)
|
if (!args.program)
|
||||||
os.exit()
|
os.exit()
|
||||||
|
|
||||||
|
prosperon.guid = args.guid
|
||||||
console.log(`going to connect to ${args.overling}`)
|
console.log(`going to connect to ${args.overling}`)
|
||||||
if (args.overling) {
|
if (args.overling)
|
||||||
// connect to the port
|
|
||||||
$_.host.connect("localhost", args.overling);
|
$_.host.connect("localhost", args.overling);
|
||||||
console.log("CONNECTING TO " + args.overling);
|
|
||||||
while(1) {
|
// spawn_root(args.program)
|
||||||
os.waitevent(_ => {}, 0.016)
|
|
||||||
$_.host.service(e => { console.log(json.encode(e)) }, 0.016)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spawn_root(args.program)
|
|
||||||
},
|
},
|
||||||
"Spawn a new prosperon actor.",
|
"Spawn a new prosperon actor.",
|
||||||
"TOPIC"
|
"TOPIC"
|
||||||
|
|||||||
@@ -127,23 +127,19 @@ static JSValue js_enet_host_service(JSContext *ctx, JSValueConst this_val,
|
|||||||
ENetEvent event;
|
ENetEvent event;
|
||||||
while (enet_host_service(host, &event, secs*1000.0f) > 0) {
|
while (enet_host_service(host, &event, secs*1000.0f) > 0) {
|
||||||
JSValue event_obj = JS_NewObject(ctx);
|
JSValue event_obj = JS_NewObject(ctx);
|
||||||
|
JSValue peer_obj = JS_NewObjectClass(ctx, enet_peer_class_id);
|
||||||
|
JS_SetOpaque(peer_obj, event.peer);
|
||||||
|
JS_SetPropertyStr(ctx, event_obj, "peer", peer_obj);
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case ENET_EVENT_TYPE_CONNECT: {
|
case ENET_EVENT_TYPE_CONNECT: {
|
||||||
JS_SetPropertyStr(ctx, event_obj, "type", JS_NewString(ctx, "connect"));
|
JS_SetPropertyStr(ctx, event_obj, "type", JS_NewString(ctx, "connect"));
|
||||||
JSValue peer_obj = JS_NewObjectClass(ctx, enet_peer_class_id);
|
|
||||||
if (JS_IsException(peer_obj)) {
|
|
||||||
JS_FreeValue(ctx, event_obj);
|
|
||||||
JS_FreeValue(ctx, callback);
|
|
||||||
return peer_obj;
|
|
||||||
}
|
|
||||||
JS_SetOpaque(peer_obj, event.peer);
|
|
||||||
JS_SetPropertyStr(ctx, event_obj, "peer", peer_obj);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ENET_EVENT_TYPE_RECEIVE: {
|
case ENET_EVENT_TYPE_RECEIVE: {
|
||||||
JS_SetPropertyStr(ctx, event_obj, "type", JS_NewString(ctx, "receive"));
|
JS_SetPropertyStr(ctx, event_obj, "type", JS_NewString(ctx, "receive"));
|
||||||
JS_SetPropertyStr(ctx, event_obj, "channelID", JS_NewInt32(ctx, event.channelID));
|
JS_SetPropertyStr(ctx, event_obj, "channelID", JS_NewInt32(ctx, event.channelID));
|
||||||
|
|
||||||
char *tmp = js_mallocz(ctx, event.packet->dataLength+1);
|
char *tmp = js_mallocz(ctx, event.packet->dataLength+1);
|
||||||
memcpy(tmp, event.packet->data, event.packet->dataLength);
|
memcpy(tmp, event.packet->data, event.packet->dataLength);
|
||||||
tmp[event.packet->dataLength] = '\0';
|
tmp[event.packet->dataLength] = '\0';
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
var os = use('os')
|
var os = use('os')
|
||||||
|
|
||||||
var newguy = os.createprocess(["./prosperon", "spawn", "--program", "spawn2.js", "--overling", $_.host.port()])
|
var guy
|
||||||
var hang = 0.016
|
|
||||||
|
|
||||||
while (1) {
|
$_.start(e => {
|
||||||
os.waitevent(_ => {}, hang)
|
console.log("Got a message: " + json.encode(e))
|
||||||
$_.host.service(e => {console.log(json.encode(e))}, hang)
|
switch(e.type) {
|
||||||
}
|
case "greet":
|
||||||
|
$_.delay(_ => {
|
||||||
|
console.log(`sending stop message to ${json.encode(e.data)}`)
|
||||||
|
$_.stop(e.data)
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
console.log(json.encode(e))
|
||||||
|
}, "tests/underling.js");
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
var os = use('os')
|
var os = use('os')
|
||||||
|
|
||||||
console.log("Created underling")
|
console.log(`started underling`)
|
||||||
|
|
||||||
os.exit()
|
|
||||||
Reference in New Issue
Block a user