You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.6 KiB
65 lines
1.6 KiB
1 year ago
|
// One day this might handle most of the [agn.host] mechanism.
|
||
|
include("again_utils.js")
|
||
|
autowatch = 1;
|
||
|
|
||
|
inlets = 1;
|
||
|
outlets = 1;
|
||
|
|
||
|
var host_name = null;
|
||
|
var top_level_patcher = null;
|
||
|
|
||
|
function loadbang() {
|
||
|
|
||
|
top_level_patcher = get_top_level_patcher();
|
||
|
host_name = jsarguments[1];
|
||
|
|
||
|
if (top_level_patcher) {
|
||
|
// post("toplevel patcher: " + top_level_patcher.name); post();
|
||
|
// outlet(0, host_name);
|
||
|
|
||
|
// check_for_other_host();
|
||
|
|
||
|
set_all_agn_host_name();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
function set_all_agn_host_name() {
|
||
|
if (top_level_patcher) {
|
||
|
top_level_patcher.applydeep(send_agn_host_name);
|
||
|
}
|
||
|
}
|
||
|
// set_all_agn_host_name.local = 0;
|
||
|
|
||
|
function send_agn_host_name (obj) {
|
||
|
if (obj.maxclass === "js") {
|
||
|
// post("js obj:" + obj.maxclass); post();
|
||
|
var patcher_name = obj.patcher.getattr("name");
|
||
|
if (["agn.remote","agn.convert"].indexOf(patcher_name) > -1) {
|
||
|
// post(obj.varname); post();
|
||
|
obj.message("set_agn_host_name", host_name);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
// send_agn_host_name.local = 0;
|
||
|
|
||
|
function request_host_name() {
|
||
|
set_all_agn_host_name();
|
||
|
}
|
||
|
// request_host_name.local = 0;
|
||
|
|
||
|
|
||
|
function check_for_other_host() {
|
||
|
top_level_patcher.applydeep(check_is_agn_host);
|
||
|
}
|
||
|
|
||
|
|
||
|
// Need some logic to detect if the currently check agn.host is this agn.host
|
||
|
function check_is_agn_host (obj) {
|
||
|
if (obj.maxclass === "js") {
|
||
|
var patcher_name = obj.patcher.getattr("name");
|
||
|
if (patcher_name === "agn.host") {
|
||
|
error("An agn.host object already exist in the patcher hierarchy. Please delete one."); post();
|
||
|
}
|
||
|
}
|
||
|
}
|