2018-02-03 02:59:36 +00:00
|
|
|
// Ooui v1.0.0
|
2017-06-13 01:24:30 +00:00
|
|
|
|
2018-02-03 04:51:05 +00:00
|
|
|
var debug = false;
|
2017-06-18 08:17:47 +00:00
|
|
|
|
2017-06-19 02:12:37 +00:00
|
|
|
const nodes = {};
|
2018-02-02 05:37:21 +00:00
|
|
|
const hasText = {};
|
2017-06-13 01:24:30 +00:00
|
|
|
|
2017-06-19 02:12:37 +00:00
|
|
|
let socket = null;
|
2018-03-10 03:39:01 +00:00
|
|
|
let wasmSession = null;
|
|
|
|
|
|
|
|
function send (json) {
|
|
|
|
if (debug) console.log ("Send", json);
|
|
|
|
if (socket != null) {
|
|
|
|
socket.send (json);
|
|
|
|
}
|
|
|
|
else if (wasmSession != null) {
|
|
|
|
WebAssemblyApp.receiveMessagesJson (wasmSession, json);
|
|
|
|
}
|
|
|
|
}
|
2017-06-13 04:50:15 +00:00
|
|
|
|
2017-07-08 05:54:03 +00:00
|
|
|
const mouseEvents = {
|
|
|
|
click: true,
|
|
|
|
dblclick: true,
|
|
|
|
mousedown: true,
|
|
|
|
mouseenter: true,
|
|
|
|
mouseleave: true,
|
|
|
|
mousemove: true,
|
|
|
|
mouseout: true,
|
|
|
|
mouseover: true,
|
|
|
|
mouseup: true,
|
|
|
|
wheel: true,
|
|
|
|
};
|
|
|
|
|
2017-11-19 20:19:44 +00:00
|
|
|
// Try to close the socket gracefully
|
2017-11-16 03:59:01 +00:00
|
|
|
window.onbeforeunload = function() {
|
|
|
|
if (socket != null) {
|
|
|
|
socket.close (1001, "Unloading page");
|
|
|
|
socket = null;
|
|
|
|
console.log ("Web socket closed");
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-11-19 20:19:44 +00:00
|
|
|
function getSize () {
|
|
|
|
return {
|
|
|
|
height: window.innerHeight,
|
|
|
|
width: window.innerWidth
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-02-02 05:02:59 +00:00
|
|
|
function setCookie (name, value, days) {
|
|
|
|
var expires = "";
|
|
|
|
if (days) {
|
|
|
|
var date = new Date ();
|
|
|
|
date.setTime(date.getTime () + (days*24*60*60*1000));
|
|
|
|
expires = "; expires=" + date.toUTCString();
|
|
|
|
}
|
|
|
|
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveSize (s) {
|
|
|
|
setCookie ("oouiWindowWidth", s.width, 7);
|
|
|
|
setCookie ("oouiWindowHeight", s.height, 7);
|
|
|
|
}
|
|
|
|
|
2017-11-19 20:19:44 +00:00
|
|
|
// Main entrypoint
|
2017-06-19 02:12:37 +00:00
|
|
|
function ooui (rootElementPath) {
|
2017-07-07 23:57:38 +00:00
|
|
|
|
2018-02-02 05:02:59 +00:00
|
|
|
var initialSize = getSize ();
|
|
|
|
saveSize (initialSize);
|
|
|
|
|
2017-11-19 20:19:44 +00:00
|
|
|
var wsArgs = (rootElementPath.indexOf("?") >= 0 ? "&" : "?") +
|
|
|
|
"w=" + initialSize.width + "&h=" + initialSize.height;
|
|
|
|
|
2018-02-01 22:23:42 +00:00
|
|
|
var proto = "ws";
|
|
|
|
if (location.protocol == "https:") {
|
|
|
|
proto = "wss";
|
|
|
|
}
|
2018-02-01 23:09:37 +00:00
|
|
|
|
2018-02-01 22:23:42 +00:00
|
|
|
socket = new WebSocket (proto + "://" + document.location.host + rootElementPath + wsArgs, "ooui");
|
2017-06-19 02:12:37 +00:00
|
|
|
|
2017-07-06 21:31:54 +00:00
|
|
|
socket.addEventListener ("open", function (event) {
|
|
|
|
console.log ("Web socket opened");
|
2017-06-19 02:12:37 +00:00
|
|
|
});
|
|
|
|
|
2017-07-06 21:31:54 +00:00
|
|
|
socket.addEventListener ("error", function (event) {
|
|
|
|
console.error ("Web socket error", event);
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.addEventListener ("close", function (event) {
|
|
|
|
console.error ("Web socket close", event);
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.addEventListener("message", function (event) {
|
2017-06-19 02:12:37 +00:00
|
|
|
const messages = JSON.parse (event.data);
|
|
|
|
if (debug) console.log("Messages", messages);
|
|
|
|
if (Array.isArray (messages)) {
|
|
|
|
messages.forEach (function (m) {
|
|
|
|
// console.log('Raw value from server', m.v);
|
|
|
|
m.v = fixupValue (m.v);
|
2018-02-03 04:18:03 +00:00
|
|
|
processMessage (m);
|
2017-06-19 02:12:37 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log("Web socket created");
|
2017-11-19 20:19:44 +00:00
|
|
|
|
2018-03-13 05:14:37 +00:00
|
|
|
monitorSizeChanges (1000/10);
|
2017-06-19 02:12:37 +00:00
|
|
|
}
|
2017-06-13 04:50:15 +00:00
|
|
|
|
2018-03-10 01:13:27 +00:00
|
|
|
function oouiWasm (mainAsmName, mainNamspace, mainClassName, mainMethodNmae, assemblies)
|
|
|
|
{
|
|
|
|
Module.assemblies = assemblies;
|
|
|
|
|
2018-03-13 05:14:37 +00:00
|
|
|
monitorSizeChanges (1000/30);
|
|
|
|
}
|
|
|
|
|
|
|
|
function monitorSizeChanges (millis)
|
|
|
|
{
|
|
|
|
var resizeTimeout;
|
|
|
|
function resizeThrottler() {
|
|
|
|
if (!resizeTimeout) {
|
|
|
|
resizeTimeout = setTimeout(function() {
|
|
|
|
resizeTimeout = null;
|
|
|
|
resizeHandler();
|
|
|
|
}, millis);
|
|
|
|
}
|
|
|
|
}
|
2018-03-10 01:13:27 +00:00
|
|
|
|
|
|
|
function resizeHandler() {
|
|
|
|
const em = {
|
|
|
|
m: "event",
|
|
|
|
id: "window",
|
|
|
|
k: "resize",
|
|
|
|
v: getSize (),
|
|
|
|
};
|
2018-03-13 05:14:37 +00:00
|
|
|
saveSize (em.v);
|
2018-03-10 01:13:27 +00:00
|
|
|
const ems = JSON.stringify (em);
|
|
|
|
send (ems);
|
|
|
|
if (debug) console.log ("Event", em);
|
|
|
|
}
|
|
|
|
|
2018-03-13 05:14:37 +00:00
|
|
|
window.addEventListener("resize", resizeThrottler, false);
|
2018-03-10 01:13:27 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 04:50:15 +00:00
|
|
|
function getNode (id) {
|
|
|
|
switch (id) {
|
|
|
|
case "window": return window;
|
|
|
|
case "document": return document;
|
2017-06-19 02:12:37 +00:00
|
|
|
case "document.body":
|
|
|
|
const bodyNode = document.getElementById ("ooui-body");
|
|
|
|
return bodyNode || document.body;
|
2017-06-13 04:50:15 +00:00
|
|
|
default: return nodes[id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-02 05:37:21 +00:00
|
|
|
function getOrCreateElement (id, tagName) {
|
|
|
|
var e = document.getElementById (id);
|
|
|
|
if (e) {
|
|
|
|
if (e.firstChild && e.firstChild.nodeType == Node.TEXT_NODE)
|
|
|
|
hasText[e.id] = true;
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
return document.createElement (tagName);
|
|
|
|
}
|
|
|
|
|
2017-06-13 04:50:15 +00:00
|
|
|
function msgCreate (m) {
|
|
|
|
const id = m.id;
|
2017-06-13 07:03:01 +00:00
|
|
|
const tagName = m.k;
|
2017-06-15 07:40:08 +00:00
|
|
|
const node = tagName === "#text" ?
|
2017-06-13 04:50:15 +00:00
|
|
|
document.createTextNode ("") :
|
2018-02-02 05:37:21 +00:00
|
|
|
getOrCreateElement (id, tagName);
|
2017-06-15 07:40:08 +00:00
|
|
|
if (tagName !== "#text")
|
2017-06-13 04:50:15 +00:00
|
|
|
node.id = id;
|
|
|
|
nodes[id] = node;
|
2017-06-18 08:17:47 +00:00
|
|
|
if (debug) console.log ("Created node", node);
|
2017-06-13 04:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function msgSet (m) {
|
|
|
|
const id = m.id;
|
|
|
|
const node = getNode (id);
|
|
|
|
if (!node) {
|
2017-06-13 07:51:24 +00:00
|
|
|
console.error ("Unknown node id", m);
|
2017-06-13 04:50:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-06-18 23:50:22 +00:00
|
|
|
const parts = m.k.split(".");
|
|
|
|
let o = node;
|
|
|
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
|
|
o = o[parts[i]];
|
|
|
|
}
|
2017-06-24 21:52:34 +00:00
|
|
|
const lastPart = parts[parts.length - 1];
|
|
|
|
const value = lastPart === "htmlFor" ? m.v.id : m.v;
|
|
|
|
o[lastPart] = value;
|
|
|
|
if (debug) console.log ("Set", node, parts, value);
|
2017-06-13 04:50:15 +00:00
|
|
|
}
|
|
|
|
|
2017-11-26 17:28:06 +00:00
|
|
|
function msgSetAttr (m) {
|
|
|
|
const id = m.id;
|
|
|
|
const node = getNode (id);
|
|
|
|
if (!node) {
|
|
|
|
console.error ("Unknown node id", m);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
node.setAttribute(m.k, m.v);
|
|
|
|
if (debug) console.log ("SetAttr", node, m.k, m.v);
|
|
|
|
}
|
|
|
|
|
2018-02-02 05:37:21 +00:00
|
|
|
function msgRemAttr (m) {
|
|
|
|
const id = m.id;
|
|
|
|
const node = getNode (id);
|
|
|
|
if (!node) {
|
|
|
|
console.error ("Unknown node id", m);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
node.removeAttribute(m.k);
|
|
|
|
if (debug) console.log ("RemAttr", node, m.k);
|
|
|
|
}
|
|
|
|
|
2017-06-13 04:50:15 +00:00
|
|
|
function msgCall (m) {
|
|
|
|
const id = m.id;
|
|
|
|
const node = getNode (id);
|
|
|
|
if (!node) {
|
2017-06-13 07:51:24 +00:00
|
|
|
console.error ("Unknown node id", m);
|
2017-06-13 04:50:15 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-02-03 04:18:03 +00:00
|
|
|
const target = node;
|
2018-02-02 05:37:21 +00:00
|
|
|
if (m.k === "insertBefore" && m.v[0].nodeType == Node.TEXT_NODE && m.v[1] == null && hasText[id]) {
|
|
|
|
// Text is already set so it clear it first
|
|
|
|
if (target.firstChild)
|
|
|
|
target.removeChild (target.firstChild);
|
|
|
|
delete hasText[id];
|
|
|
|
}
|
2018-02-03 04:18:03 +00:00
|
|
|
const f = target[m.k];
|
2017-06-18 08:17:47 +00:00
|
|
|
if (debug) console.log ("Call", node, f, m.v);
|
2017-12-10 22:21:49 +00:00
|
|
|
const r = f.apply (target, m.v);
|
2017-06-19 07:08:33 +00:00
|
|
|
if (typeof m.rid === 'string' || m.rid instanceof String) {
|
|
|
|
nodes[m.rid] = r;
|
|
|
|
}
|
2017-06-13 04:50:15 +00:00
|
|
|
}
|
|
|
|
|
2017-06-15 07:40:08 +00:00
|
|
|
function msgListen (m) {
|
2017-06-15 07:58:55 +00:00
|
|
|
const node = getNode (m.id);
|
|
|
|
if (!node) {
|
|
|
|
console.error ("Unknown node id", m);
|
|
|
|
return;
|
|
|
|
}
|
2017-06-18 08:17:47 +00:00
|
|
|
if (debug) console.log ("Listen", node, m.k);
|
2017-07-06 21:19:06 +00:00
|
|
|
node.addEventListener(m.k, function (e) {
|
2017-06-15 07:58:55 +00:00
|
|
|
const em = {
|
|
|
|
m: "event",
|
|
|
|
id: m.id,
|
|
|
|
k: m.k,
|
|
|
|
};
|
2017-06-19 05:28:14 +00:00
|
|
|
if (m.k === "change" || m.k === "input") {
|
2017-06-24 22:21:48 +00:00
|
|
|
em.v = (node.tagName === "INPUT" && node.type === "checkbox") ?
|
|
|
|
node.checked :
|
|
|
|
node.value;
|
2017-06-16 06:27:07 +00:00
|
|
|
}
|
2017-07-08 05:54:03 +00:00
|
|
|
else if (mouseEvents[m.k]) {
|
|
|
|
em.v = {
|
|
|
|
offsetX: e.offsetX,
|
|
|
|
offsetY: e.offsetY,
|
|
|
|
};
|
|
|
|
}
|
2017-06-15 07:58:55 +00:00
|
|
|
const ems = JSON.stringify (em);
|
2018-03-10 03:39:01 +00:00
|
|
|
send (ems);
|
2017-06-18 08:17:47 +00:00
|
|
|
if (debug) console.log ("Event", em);
|
2017-07-06 21:19:06 +00:00
|
|
|
if (em.k === "submit")
|
|
|
|
e.preventDefault ();
|
2017-06-15 07:58:55 +00:00
|
|
|
});
|
2017-06-15 07:40:08 +00:00
|
|
|
}
|
|
|
|
|
2017-06-13 04:50:15 +00:00
|
|
|
function processMessage (m) {
|
|
|
|
switch (m.m) {
|
2017-06-13 07:03:01 +00:00
|
|
|
case "nop":
|
|
|
|
break;
|
|
|
|
case "create":
|
2017-06-13 04:50:15 +00:00
|
|
|
msgCreate (m);
|
|
|
|
break;
|
2017-06-13 07:03:01 +00:00
|
|
|
case "set":
|
2017-06-13 04:50:15 +00:00
|
|
|
msgSet (m);
|
|
|
|
break;
|
2017-11-26 17:28:06 +00:00
|
|
|
case "setAttr":
|
|
|
|
msgSetAttr (m);
|
|
|
|
break;
|
2018-02-02 05:37:21 +00:00
|
|
|
case "remAttr":
|
|
|
|
msgRemAttr (m);
|
|
|
|
break;
|
2017-06-13 07:03:01 +00:00
|
|
|
case "call":
|
2017-06-13 04:50:15 +00:00
|
|
|
msgCall (m);
|
|
|
|
break;
|
2017-06-15 07:40:08 +00:00
|
|
|
case "listen":
|
|
|
|
msgListen (m);
|
|
|
|
break;
|
2017-06-13 04:50:15 +00:00
|
|
|
default:
|
|
|
|
console.error ("Unknown message type", m.m, m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function fixupValue (v) {
|
|
|
|
if (Array.isArray (v)) {
|
|
|
|
for (x in v) {
|
|
|
|
v[x] = fixupValue (v[x]);
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
else if (typeof v === 'string' || v instanceof String) {
|
2017-06-15 09:39:19 +00:00
|
|
|
if ((v.length > 1) && (v[0] === "\u2999")) {
|
2017-06-13 07:03:01 +00:00
|
|
|
// console.log("V", v);
|
2017-06-15 09:39:19 +00:00
|
|
|
return getNode (v);
|
2017-06-13 04:50:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
2018-03-10 01:13:27 +00:00
|
|
|
|
|
|
|
// == WASM Support ==
|
|
|
|
|
2018-03-10 03:11:57 +00:00
|
|
|
window["__oouiReceiveMessages"] = function (sessionId, messages)
|
|
|
|
{
|
2018-03-10 03:39:01 +00:00
|
|
|
if (debug) console.log ("WebAssembly Receive", messages);
|
2018-03-13 05:14:37 +00:00
|
|
|
if (wasmSession != null) {
|
|
|
|
messages.forEach (function (m) {
|
|
|
|
// console.log ('Raw value from server', m.v);
|
|
|
|
m.v = fixupValue (m.v);
|
|
|
|
processMessage (m);
|
|
|
|
});
|
|
|
|
}
|
2018-03-10 03:11:57 +00:00
|
|
|
};
|
|
|
|
|
2018-03-10 01:13:27 +00:00
|
|
|
var Module = {
|
|
|
|
onRuntimeInitialized: function () {
|
2018-03-10 03:39:01 +00:00
|
|
|
if (debug) console.log ("Done with WASM module instantiation.");
|
2018-03-10 01:13:27 +00:00
|
|
|
|
|
|
|
Module.FS_createPath ("/", "managed", true, true);
|
|
|
|
|
|
|
|
var pending = 0;
|
|
|
|
this.assemblies.forEach (function(asm_name) {
|
2018-03-10 03:39:01 +00:00
|
|
|
if (debug) console.log ("Loading", asm_name);
|
2018-03-10 01:13:27 +00:00
|
|
|
++pending;
|
|
|
|
fetch ("managed/" + asm_name, { credentials: 'same-origin' }).then (function (response) {
|
|
|
|
if (!response.ok)
|
|
|
|
throw "failed to load Assembly '" + asm_name + "'";
|
|
|
|
return response['arrayBuffer']();
|
|
|
|
}).then (function (blob) {
|
|
|
|
var asm = new Uint8Array (blob);
|
|
|
|
Module.FS_createDataFile ("managed/" + asm_name, null, asm, true, true, true);
|
|
|
|
--pending;
|
|
|
|
if (pending == 0)
|
|
|
|
Module.bclLoadingDone ();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
bclLoadingDone: function () {
|
2018-03-10 03:39:01 +00:00
|
|
|
if (debug) console.log ("Done loading the BCL.");
|
2018-03-10 01:13:27 +00:00
|
|
|
MonoRuntime.init ();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var MonoRuntime = {
|
|
|
|
init: function () {
|
|
|
|
this.load_runtime = Module.cwrap ('mono_wasm_load_runtime', null, ['string', 'number']);
|
|
|
|
this.assembly_load = Module.cwrap ('mono_wasm_assembly_load', 'number', ['string']);
|
|
|
|
this.find_class = Module.cwrap ('mono_wasm_assembly_find_class', 'number', ['number', 'string', 'string']);
|
|
|
|
this.find_method = Module.cwrap ('mono_wasm_assembly_find_method', 'number', ['number', 'string', 'number']);
|
|
|
|
this.invoke_method = Module.cwrap ('mono_wasm_invoke_method', 'number', ['number', 'number', 'number']);
|
|
|
|
this.mono_string_get_utf8 = Module.cwrap ('mono_wasm_string_get_utf8', 'number', ['number']);
|
|
|
|
this.mono_string = Module.cwrap ('mono_wasm_string_from_js', 'number', ['string']);
|
|
|
|
|
|
|
|
this.load_runtime ("managed", 1);
|
|
|
|
|
2018-03-10 03:39:01 +00:00
|
|
|
if (debug) console.log ("Done initializing the runtime.");
|
2018-03-10 01:13:27 +00:00
|
|
|
|
|
|
|
WebAssemblyApp.init ();
|
|
|
|
},
|
|
|
|
|
|
|
|
conv_string: function (mono_obj) {
|
|
|
|
if (mono_obj == 0)
|
|
|
|
return null;
|
|
|
|
var raw = this.mono_string_get_utf8 (mono_obj);
|
|
|
|
var res = Module.UTF8ToString (raw);
|
|
|
|
Module._free (raw);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
},
|
|
|
|
|
|
|
|
call_method: function (method, this_arg, args) {
|
|
|
|
var args_mem = Module._malloc (args.length * 4);
|
|
|
|
var eh_throw = Module._malloc (4);
|
|
|
|
for (var i = 0; i < args.length; ++i)
|
|
|
|
Module.setValue (args_mem + i * 4, args [i], "i32");
|
|
|
|
Module.setValue (eh_throw, 0, "i32");
|
|
|
|
|
|
|
|
var res = this.invoke_method (method, this_arg, args_mem, eh_throw);
|
|
|
|
|
|
|
|
var eh_res = Module.getValue (eh_throw, "i32");
|
|
|
|
|
|
|
|
Module._free (args_mem);
|
|
|
|
Module._free (eh_throw);
|
|
|
|
|
|
|
|
if (eh_res != 0) {
|
|
|
|
var msg = this.conv_string (res);
|
|
|
|
throw new Error (msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var WebAssemblyApp = {
|
|
|
|
init: function () {
|
|
|
|
this.loading = document.getElementById ("loading");
|
|
|
|
|
|
|
|
this.findMethods ();
|
|
|
|
|
|
|
|
var res = this.runApp ("1", "2");
|
|
|
|
|
|
|
|
this.loading.hidden = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
runApp: function (a, b) {
|
|
|
|
try {
|
2018-03-10 03:39:01 +00:00
|
|
|
var sessionId = "main";
|
|
|
|
var rres = MonoRuntime.call_method (this.main_method, null, [MonoRuntime.mono_string (a), MonoRuntime.mono_string (b)]);
|
2018-03-10 03:11:57 +00:00
|
|
|
var res = MonoRuntime.conv_string (rres);
|
2018-03-10 03:39:01 +00:00
|
|
|
wasmSession = sessionId;
|
2018-03-13 05:14:37 +00:00
|
|
|
var initialSize = getSize ();
|
|
|
|
MonoRuntime.call_method (this.ooui_StartWebAssemblySession_method, null, [MonoRuntime.mono_string (sessionId), MonoRuntime.mono_string ("main"), MonoRuntime.mono_string (Math.round(initialSize.width) + " " + Math.round(initialSize.height))]);
|
2018-03-10 03:11:57 +00:00
|
|
|
return res;
|
2018-03-10 01:13:27 +00:00
|
|
|
} catch (e) {
|
|
|
|
return e.msg;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-03-10 03:39:01 +00:00
|
|
|
receiveMessagesJson: function (sessionId, json) {
|
|
|
|
MonoRuntime.call_method (this.ooui_ReceiveWebAssemblySessionMessageJson_method, null, [MonoRuntime.mono_string (sessionId), MonoRuntime.mono_string (json)]);
|
|
|
|
},
|
|
|
|
|
2018-03-10 01:13:27 +00:00
|
|
|
findMethods: function () {
|
2018-03-10 03:39:01 +00:00
|
|
|
this.ooui_module = MonoRuntime.assembly_load ("Ooui");
|
2018-03-10 01:13:27 +00:00
|
|
|
if (!this.ooui_module)
|
|
|
|
throw "Could not find Ooui.dll";
|
|
|
|
|
2018-03-10 03:39:01 +00:00
|
|
|
this.ooui_class = MonoRuntime.find_class (this.ooui_module, "Ooui", "UI");
|
2018-03-10 01:13:27 +00:00
|
|
|
if (!this.ooui_class)
|
|
|
|
throw "Could not find UI class in Ooui module";
|
|
|
|
|
2018-03-10 03:39:01 +00:00
|
|
|
this.ooui_StartWebAssemblySession_method = MonoRuntime.find_method (this.ooui_class, "StartWebAssemblySession", -1);
|
|
|
|
if (!this.ooui_StartWebAssemblySession_method)
|
2018-03-10 01:13:27 +00:00
|
|
|
throw "Could not find StartWebAssemblySession method";
|
|
|
|
|
2018-03-10 03:39:01 +00:00
|
|
|
this.ooui_ReceiveWebAssemblySessionMessageJson_method = MonoRuntime.find_method (this.ooui_class, "ReceiveWebAssemblySessionMessageJson", -1);
|
|
|
|
if (!this.ooui_ReceiveWebAssemblySessionMessageJson_method)
|
|
|
|
throw "Could not find ReceiveWebAssemblySessionMessageJson method";
|
|
|
|
|
|
|
|
this.main_module = MonoRuntime.assembly_load (mainAsmName);
|
2018-03-10 01:13:27 +00:00
|
|
|
if (!this.main_module)
|
|
|
|
throw "Could not find Main Module " + mainAsmName + ".dll";
|
|
|
|
|
2018-03-10 03:39:01 +00:00
|
|
|
this.main_class = MonoRuntime.find_class (this.main_module, "", "Program")
|
|
|
|
if (!this.main_class)
|
2018-03-10 01:13:27 +00:00
|
|
|
throw "Could not find Program class in main module";
|
|
|
|
|
2018-03-10 03:39:01 +00:00
|
|
|
this.main_method = MonoRuntime.find_method (this.main_class, "Main", -1)
|
|
|
|
if (!this.main_method)
|
2018-03-10 01:13:27 +00:00
|
|
|
throw "Could not find Main method";
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|