jstoue.js 1.3 KB

12345678910111213141516171819202122
  1. "object"!=typeof ue &&(delete ue ,ue={});
  2. "object" != typeof ue.interface && (delete ue.interface , ue.interface={});
  3. "function" != typeof ue.call && (ue.call = function (functoid) {
  4. return function (key, json, cback, timeout) {
  5. if ("object" != typeof ue["$receive"] || "function" != typeof ue["$receive"]["asyn"]) {
  6. console.error("[ue.$receive.asyn] drop message .... key" + key + " json" + JSON.stringify(json));
  7. return;
  8. }
  9. "string" == typeof key && ("function" == typeof json && (timeout = cback, cback = json, json = null));
  10. var backid = functoid(cback, timeout);
  11. void "string" !== typeof json ? ue["$receive"].asyn(key, JSON.stringify(json), backid) : ue["$receive"].asyn(key, json, backid);
  12. };
  13. }(
  14. function (callback, timeout) {
  15. if ("function" != typeof callback)
  16. return "";
  17. var funcid = function () { return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, function (t) { return (t ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> t / 4).toString(16) }) }();
  18. return ue.interface[funcid] = callback, setTimeout(function () { delete ue.interface[funcid] }, 1e3 * Math.max(2, parseInt(timeout) || 0)), funcid
  19. }
  20. ));
  21. "function" != typeof ue4 && (delete ue4, ue4=ue.call);