public int action(int t, object p) { int r = 0; jsc.sync(_ => r = (int)instance(t, p)); return(r); }
public JavaScriptHandle(JsContext jsc, string init, ICollection <int> providers, DictionaryCache cache) { this.jsc = jsc; this.cache = cache; jsc.sync(js => { js.name("limax.js").eval(limax.script.codes.js.limax); js.name("cache").eval("var cache=<0>", cache); js.name("initscript").eval(init); if (providers == null || providers.Count == 0) { foreach (object pvid in (JsArray)js.eval("providers")) { this.providers.Add((int)pvid); } } else { foreach (var pvid in providers) { this.providers.Add(pvid); } } this.instance = (JsFunction)js.name("").eval("limax"); }); }
public JavaScriptHandle(JsContext jsc, string init, ICollection <int> providers, DictionaryCache cache, TunnelReceivier ontunnel) { this.jsc = jsc; this.cache = cache != null ? cache : new SimpleDictionaryCache(); TunnelReceivier _ontunnel = (providerid, label, data) => { if (providerid == AuanyService.providerId) { if (lmkDataReceiver != null) { lmkDataReceiver.onLmkData(data, () => tunnel(AuanyService.providerId, -1, "")); } } else if (ontunnel != null) { ontunnel(providerid, label, data); } }; jsc.sync(js => { js.name("limax.js").eval(limax.script.codes.js.limax); js.name("cache").eval("var cache=<0>", this.cache); js.name("ontunnel").eval("var ontunnel=<0>", _ontunnel); js.name("initscript").eval(init); if (providers == null || providers.Count == 0) { foreach (object pvid in (JsArray)js.eval("providers")) { this.providers.Add((int)pvid); } } else { foreach (var pvid in providers) { this.providers.Add(pvid); } } this.instance = (JsFunction)js.name("").eval("limax"); }); }