Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @license 3DconnexionJS
- *
- * Copyright (c) 2013-2016 3Dconnexion. All rights reserved.
- * License:
- * This file is licensed under the terms of the "3Dconnexion
- * Software Development Kit" license agreement:
- * http://www.3dconnexion.com/service/software-developer/licence-agreement.html
- * All rights not expressly granted by 3Dconnexion are reserved.
- *
- * $Revision: 13777 $
- */
- var _3Dconnexion = function(n) {
- "use strict";
- this.version = "0.4.0";
- this.client = n;
- this.session = null;
- this.defport = 8181;
- this.connected = !1;
- this.connexion = null;
- this._3dcontroller = null;
- this.viewport = null;
- this.host = "127.51.68.120";
- this.nlRpcUri = null;
- this.nlResourceUri = null;
- this._EVENT_TYPEID_RPC = 0;
- this.V3DK_FIT = 31;
- this.V3DK_MENU = 30;
- this.fnUpdate = {
- motion: this.onMotion.bind(this),
- "events.keyPress": this.onKeyPress.bind(this),
- "events.keyRelease": this.onKeyRelease.bind(this)
- };
- this.clientFnRead = {
- "view.affine": n.getViewMatrix,
- "view.constructionPlane": n.getConstructionPlane,
- "view.extents": n.getViewExtents,
- "view.fov": n.getFov,
- "view.frustum": n.getViewFrustum,
- "view.perspective": n.getPerspective,
- "view.target": n.getViewTarget,
- "view.rotatable": n.getViewRotatable,
- "model.extents": n.getModelExtents,
- "pivot.position": n.getPivotPosition,
- "hit.lookat": n.getLookAt,
- "selection.empty": n.getSelectionEmpty,
- "selection.extents": n.getSelectionExtents,
- "pointer.position": n.getPointerPosition,
- coordinateSystem: n.getCoordinateSystem,
- "views.front": n.getFrontView
- };
- this.clientFnUpdate = {
- motion: n.putMoving,
- "view.affine": n.putViewMatrix,
- "view.extents": n.putViewExtents,
- "view.fov": n.putFov,
- "view.target": n.putTarget,
- "commands.activeCommand": n.putActiveCommand,
- "pivot.position": n.putPivotPosition,
- "pivot.visible": n.putPivotVisible,
- "hit.lookfrom": n.putLookFrom,
- "hit.direction": n.putLookDirection,
- "hit.aperture": n.putLookAperture,
- "hit.selectionOnly": n.putSelectionOnly,
- "events.keyPress": n.putKeyPress,
- "events.keyRelease": n.putKeyRelease
- };
- this.debug = !1;
- window.hasOwnProperty("_3DCONNEXION_DEBUG") && (this.debug = window._3DCONNEXION_DEBUG)
- },
- CryptoJS, AUTOBAHNJS_VERSION, global;
- _3Dconnexion.prototype.connect = function() {
- "use strict";
- var n = this,
- e = this.client,
- u = 1,
- t = new XMLHttpRequest,
- f, r, i;
- if (!e.onConnect) throw "onConnect handler required!";
- i = "https://" + n.host + ":" + n.defport + "/3dconnexion/nlproxy";
- t.onreadystatechange = function() {
- if (t.readyState === 4 && t.status === 200) {
- n.debug && console.log(t.responseText);
- n.nlRpcUri = "wss://" + n.host + "/3dconnexion#";
- n.nlResourceUri = "wss://" + n.host + "/3dconnexion";
- try {
- f = JSON.parse(t.responseText).port;
- r = "wss://" + n.host + ":" + f;
- n.debug && console.log("Connecting to " + r + " ...");
- window.hasOwnProperty("AUTOBAHN_DEBUG") && window.AUTOBAHN_DEBUG && window.ab.debug(!0, !0, !0);
- window.ab.connect(r, function(t) {
- n.session = t;
- n.connected = !0;
- n.debug && console.log("Connected!");
- t.prefix("3dx_rpc", n.nlRpcUri);
- t.prefix("3dconnexion", n.nlResourceUri);
- t.prefix("self", window.location.href);
- n.client.onConnect()
- }, function(t, i) {
- if (n.client.onDisconnect !== undefined) n.client.onDisconnect(i);
- n.delete3dmouse();
- n.connected = !1;
- n.session = null;
- n.debug && console.log("Socket closed!", i)
- }, {
- maxRetries: 3,
- retryDelay: 500
- })
- } catch (i) {
- console.error(i)
- }
- }
- };
- t.onerror = function() {
- n.debug && console.log("_3Dconnexion.connect: No response from local 3dmouse server " + i)
- };
- t.ontimeout = function() {
- n.debug && console.log("_3Dconnexion.connect: Timeout querying local 3dmouse server " + i)
- };
- try {
- t.open("GET", i, !0);
- t.setRequestHeader("Accept", "application/json; charset=utf-8");
- t.msCaching = "disabled";
- t.timeout = 0;
- t.send()
- } catch (o) {
- u = 0;
- console.error(o.toString())
- }
- return u
- };
- _3Dconnexion.prototype.create3dmouse = function(n, t) {
- "use strict";
- var i = this;
- i.viewport = n;
- i.debug && console.log("create3dmouse " + i.viewport.id);
- $(i.viewport).on("focus", i.focus.bind(i));
- $(i.viewport).on("blur", i.blur.bind(i));
- i.session.call("3dx_rpc:create", "3dconnexion:3dmouse", i.version).then(function(n) {
- i.connexion = n.connexion;
- var r = {
- version: 0,
- name: t
- };
- i.session.call("3dx_rpc:create", "3dconnexion:3dcontroller", i.connexion, r).then(function(n) {
- i._3dcontroller = n.instance;
- i.session.subscribe("3dconnexion:3dcontroller/" + i._3dcontroller, i.onEvent.bind(i));
- document.hasFocus() && (document.activeElement === document.body || document.activeElement === null ? (i.viewport.focus(), window === i.viewport && i.focus()) : (document.activeElement === i.viewport || $(i.viewport).find(document.activeElement).length > 0) && (i.focus(), i.debug && console.log("self.viewport has focus")));
- i.client.on3dmouseCreated && i.client.on3dmouseCreated()
- }, function(n) {
- console.log("3dx_rpc:create 3dconnexion:3dcontroller " + n)
- })
- }, function(n) {
- console.log("3dx_rpc:create " + n)
- })
- };
- _3Dconnexion.prototype.blur = function() {
- "use strict";
- var n = this;
- n.debug && console.log("blur on ");
- n.session && n._3dcontroller && n.update3dcontroller({
- focus: !1
- })
- };
- _3Dconnexion.prototype.focus = function() {
- "use strict";
- var n = this;
- n.debug && console.log("focus on ");
- n.session && n._3dcontroller && n.update3dcontroller({
- focus: !0
- })
- };
- _3Dconnexion.prototype.onKeyPress = function(n) {
- "use strict";
- var t = this;
- t.debug && console.log("onKeyPress " + n)
- };
- _3Dconnexion.prototype.onKeyRelease = function(n) {
- "use strict";
- var t = this;
- t.debug && console.log("onKeyRelease " + n)
- };
- _3Dconnexion.prototype.onMotion = function(n) {
- "use strict";
- var t = this;
- n === !0 ? t.client.onStartMotion !== undefined && t.client.onStartMotion() : t.client.onStopMotion !== undefined && t.client.onStopMotion()
- };
- _3Dconnexion.prototype.onEvent = function(n, t) {
- "use strict";
- var i = this,
- f = null,
- r = null,
- u = null;
- if (i.debug && (console.log(n), console.log(t)), t[0] === window.ab._MESSAGE_TYPEID_CALL) {
- if (t[2] === "self:read")
- if (r = i.clientFnRead[t[4]], r !== undefined) f = r.bind(i.client)();
- else {
- u = [window.ab._MESSAGE_TYPEID_CALL_ERROR, t[1], t[2] + "#generic", t[4] + " unknown property"];
- i.session._send(u);
- return
- }
- else if (t[2] === "self:update")
- if (r = i.fnUpdate[t[4]], r !== undefined) f = r(t[5]);
- else if (r = i.clientFnUpdate[t[4]], r !== undefined) f = r.bind(i.client)(t[5]);
- else {
- u = [window.ab._MESSAGE_TYPEID_CALL_ERROR, t[1], t[2] + "#generic", t[4] + " unknown property"];
- i.session._send(u);
- return
- } else {
- u = [window.ab._MESSAGE_TYPEID_CALL_ERROR, t[1], t[2] + "#generic", "unknown procedure"];
- i.session._send(u);
- return
- }
- u = [window.ab._MESSAGE_TYPEID_CALL_RESULT, t[1], f];
- i.session._send(u)
- }
- };
- _3Dconnexion.prototype.read3dcontroller = function(n, t) {
- "use strict";
- var i = this;
- i.debug && console.log("read3dcontroller " + i._3dcontroller);
- try {
- i.session.call("3dx_rpc:read", "3dconnexion:3dcontroller/" + i._3dcontroller, n).then(function(n) {
- t && t(n)
- }, function(t) {
- console.log("3dx_rpc:read 3dconnexion:3dcontroller/" + i._3dcontroller + " " + n + " " + t)
- })
- } catch (r) {
- console.error(r)
- }
- };
- _3Dconnexion.prototype.update3dcontroller = function(n) {
- "use strict";
- var t = this;
- t.debug && console.log("update3dmouse " + t._3dcontroller);
- try {
- if (!t._3dcontroller) throw "exception 3dx_rpc:update: 3dcontroller not initialized";
- t.session.call("3dx_rpc:update", "3dconnexion:3dcontroller/" + t._3dcontroller, n).then(function() {
- return
- }, function(n) {
- console.log("3dx_rpc:update 3dconnexion:3dcontroller/" + t._3dcontroller + " " + n)
- })
- } catch (i) {
- console.error(i)
- }
- };
- _3Dconnexion.prototype.delete3dmouse = function() {
- "use strict";
- var n = this,
- t = n.connexion;
- n.debug && console.log("delete3dmouse ");
- n.connexion = null;
- n._3dcontroller = null;
- n.viewport !== null && ($(n.viewport).off("focus"), $(n.viewport).off("blur"));
- n.session && n.session.call("3dx_rpc:delete", "3dconnexion:3dmouse/" + t).then(function() {
- n.debug && console.log("deleted connexion " + t)
- }, function(n) {
- console.log("3dx_rpc:delete " + t + " " + n)
- })
- };
- Object.freeze(_3Dconnexion.SiActionNodeType_t = {
- SI_ACTIONSET_NODE: 0,
- SI_CATEGORY_NODE: 1,
- SI_ACTION_NODE: 2
- });
- _3Dconnexion.ActionNode = function(n, t, i) {
- return this.id = n, this.label = t || n, this.type = i, this
- };
- _3Dconnexion.ActionNode.prototype = {
- constructor: _3Dconnexion.ActionNode,
- id: {
- value: null,
- enumerable: !0
- },
- label: {
- value: null,
- writable: !0,
- enumerable: !0
- },
- type: {
- value: null,
- enumerable: !0
- }
- };
- _3Dconnexion.Action = function(n, t, i) {
- return _3Dconnexion.ActionNode.call(this, n, t, _3Dconnexion.SiActionNodeType_t.SI_ACTION_NODE), this.description = i || "", this
- };
- _3Dconnexion.Action.prototype = Object.create(_3Dconnexion.ActionNode.prototype, {
- constructor: {
- value: _3Dconnexion.Action
- },
- description: {
- value: "",
- writable: !0,
- enumerable: !0
- }
- });
- _3Dconnexion.ActionTreeNode = function() {
- return this.nodes = [], this
- };
- _3Dconnexion.ActionTreeNode.prototype = Object.create(_3Dconnexion.ActionNode.prototype, {
- constructor: {
- value: _3Dconnexion.ActionTreeNode
- },
- nodes: {
- value: null,
- writable: !0,
- enumerable: !0
- },
- push: {
- value: function(n) {
- return this.nodes.push(n), n
- }
- }
- });
- _3Dconnexion.ActionSet = function(n, t) {
- return _3Dconnexion.ActionNode.call(this, n, t, _3Dconnexion.SiActionNodeType_t.SI_ACTIONSET_NODE), _3Dconnexion.ActionTreeNode.call(this), this
- };
- _3Dconnexion.ActionSet.prototype = Object.create(_3Dconnexion.ActionTreeNode.prototype, {
- constructor: {
- value: _3Dconnexion.ActionSet
- }
- });
- _3Dconnexion.Category = function(n, t) {
- return _3Dconnexion.ActionNode.call(this, n, t, _3Dconnexion.SiActionNodeType_t.SI_CATEGORY_NODE), _3Dconnexion.ActionTreeNode.call(this), this
- };
- _3Dconnexion.Category.prototype = Object.create(_3Dconnexion.ActionTreeNode.prototype, {
- constructor: {
- value: _3Dconnexion.Category
- }
- });
- _3Dconnexion.ActionTree = function() {
- return this.nodes = [], this
- };
- _3Dconnexion.ActionTree.prototype = Object.create(null, {
- constructor: {
- value: _3Dconnexion.ActionTree
- },
- nodes: {
- value: null,
- writable: !0,
- enumerable: !0
- },
- push: {
- value: function(n) {
- return this.nodes.push(n), n
- }
- }
- });
- _3Dconnexion.ImageItem = function() {};
- Object.freeze(_3Dconnexion.SiImageType_t = {
- e_none: 0,
- e_image_file: 1,
- e_resource_file: 2,
- e_image: 3
- });
- _3Dconnexion.ImageItem.prototype = {
- constructor: _3Dconnexion.ImageItem,
- id: {
- value: "",
- writable: !0
- },
- type: {
- value: "e_none",
- enumerable: !0
- }
- };
- _3Dconnexion.ImageItem.fromImage = function(n, t) {
- var i = new _3Dconnexion.ImageItem;
- return Object.defineProperties(i, {
- id: {
- value: t || "",
- writable: !0,
- enumerable: !0
- },
- type: {
- value: _3Dconnexion.SiImageType_t.e_image,
- enumerable: !0
- },
- index: {
- value: 0,
- writable: !0,
- enumerable: !0
- },
- data: {
- value: _3Dconnexion.ImageItem.base64FromArrayBuffer(n),
- enumerable: !0
- },
- status: {
- value: 200
- }
- })
- };
- _3Dconnexion.ImageItem.fromURL = function(n, t) {
- var r = new _3Dconnexion.ImageItem,
- i;
- return Object.defineProperties(r, {
- id: {
- value: t || "",
- writable: !0,
- enumerable: !0
- },
- type: {
- value: _3Dconnexion.SiImageType_t.e_image,
- enumerable: !0
- },
- index: {
- value: 0,
- writable: !0,
- enumerable: !0
- },
- buffer: {
- value: null,
- writable: !0
- },
- data: {
- get: function() {
- return this.buffer
- },
- set: function(n) {
- r.buffer = n;
- r.onload()
- },
- enumerable: !0
- },
- status: {
- value: 100,
- writable: !0
- },
- onload: {
- value: function() {},
- writable: !0
- }
- }), i = new XMLHttpRequest, i.overrideMimeType("text/plain; charset=x-user-defined"), i.open("GET", n, !0), i.responseType = "arraybuffer", i.onload = function() {
- if (r.status = i.status, i.status === 200 && i.response !== null) {
- r.data = _3Dconnexion.ImageItem.base64FromArrayBuffer(i.response);
- return
- }
- r.status = 404;
- r.data = null
- }, i.onerror = function() {
- r.status = i.status;
- r.data = null
- }, i.send(null), r
- };
- _3Dconnexion.ImageItem.base64FromArrayBuffer = function(n) {
- for (var u = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", t = new Uint8Array(n), e = t.length % 3, f = t.length - e, i = "", r = 0; r < f; r += 3) i += u[t[r] >> 2], i += u[(t[r] & 3) << 4 | t[r + 1] >> 4], i += u[(t[r + 1] & 15) << 2 | t[r + 2] >> 6], i += u[t[r + 2] & 63];
- return e !== 0 && (i += u[t[f] >> 2], e === 2 ? (i += u[(t[f] & 3) << 4 | t[f + 1] >> 4], i += u[(t[f + 1] & 15) << 2], i += "=") : (i += u[(t[f] & 3) << 4], i += "==")), i
- };
- _3Dconnexion.ImageCache = function() {
- this.images = [];
- this.outstanding_requests = 0
- };
- _3Dconnexion.ImageCache.prototype = {
- constructor: _3Dconnexion.ImageCache,
- images: {
- value: null,
- writable: !0,
- enumerable: !0
- },
- outstanding_requests: {
- value: 0,
- writable: !0
- },
- push: function(n) {
- var t = this;
- if (n.status === 100) ++t.outstanding_requests, n.onload = function() {
- var n = this,
- i;
- n.onload = function() {};
- n.status !== 200 && (i = t.images.indexOf(n), i > -1 && t.images.splice(i, 1));
- --t.outstanding_requests;
- t.outstanding_requests === 0 && t.onload()
- }.bind(n);
- else if (n.data === null) return;
- t.images.push(n)
- },
- onload: function() {}
- };
- /** @license AutobahnJS - http://autobahn.ws
- *
- * Copyright (C) 2011-2014 Tavendo GmbH.
- * Licensed under the MIT License.
- * See license text at http://www.opensource.org/licenses/mit-license.php
- *
- * AutobahnJS includes code from:
- *
- * when - http://cujojs.com
- *
- * (c) copyright B Cavalier & J Hann
- * Licensed under the MIT License at:
- * http://www.opensource.org/licenses/mit-license.php
- *
- * Crypto-JS - http://code.google.com/p/crypto-js/
- *
- * (c) 2009-2012 by Jeff Mott. All rights reserved.
- * Licensed under the New BSD License at:
- * http://code.google.com/p/crypto-js/wiki/License
- *
- * console-normalizer - https://github.com/Zenovations/console-normalizer
- *
- * (c) 2012 by Zenovations.
- * Licensed under the MIT License at:
- * http://www.opensource.org/licenses/mit-license.php
- *
- */
- window.define || (window.define = function(n) {
- try {
- delete window.define
- } catch (t) {
- window.define = void 0
- }
- window.when = n()
- }, window.define.amd = {}),
- function(n) {
- n || (n = window.console = {
- log: function() {},
- info: function() {},
- warn: function() {},
- error: function() {}
- });
- Function.prototype.bind || (Function.prototype.bind = function(n) {
- var t = this,
- i = Array.prototype.slice.call(arguments, 1);
- return function() {
- return t.apply(n, Array.prototype.concat.apply(i, arguments))
- }
- });
- typeof n.log == "object" && (n.log = Function.prototype.call.bind(n.log, n), n.info = Function.prototype.call.bind(n.info, n), n.warn = Function.prototype.call.bind(n.warn, n), n.error = Function.prototype.call.bind(n.error, n));
- "group" in n || (n.group = function(t) {
- n.info("\n--- " + t + " ---\n")
- });
- "groupEnd" in n || (n.groupEnd = function() {
- n.log("\n")
- });
- "time" in n || function() {
- var t = {};
- n.time = function(n) {
- t[n] = (new Date).getTime()
- };
- n.timeEnd = function(i) {
- var r = (new Date).getTime(),
- u = i in t ? r - t[i] : 0;
- n.info(i + ": " + u + "ms")
- }
- }()
- }(window.console);
- /** @license MIT License (c) copyright 2011-2013 original author or authors */
- (function(n) {
- "use strict";
- n(function(n) {
- function t(n, t, i, r) {
- return at(n).then(t, i, r)
- }
- function e(n) {
- return new f(n, h.PromiseStatus && h.PromiseStatus())
- }
- function f(n, t) {
- function c() {
- return f ? f.inspect() : ii()
- }
- function l(n, t, r, u, e) {
- function o(i) {
- i._when(n, t, r, u, e)
- }
- i ? i.push(o) : y(function() {
- o(f)
- })
- }
- function o(n) {
- if (i) {
- var r = i;
- i = u;
- y(function() {
- f = pt(e, n);
- t && bt(f, t);
- w(r, f)
- })
- }
- }
- function s(n) {
- o(new r(n))
- }
- function a(n) {
- if (i) {
- var t = i;
- y(function() {
- w(t, new b(n))
- })
- }
- }
- var e, f, i = [];
- e = this;
- this._status = t;
- this.inspect = c;
- this._when = l;
- try {
- n(o, s, a)
- } catch (h) {
- s(h)
- }
- }
- function at(n) {
- return n instanceof f ? n : o(n)
- }
- function o(n) {
- return e(function(t) {
- t(n)
- })
- }
- function vt(n) {
- return t(n, function(n) {
- return new r(n)
- })
- }
- function yt() {
- function f(u, f, e) {
- n.resolve = n.resolver.resolve = function(n) {
- return t ? o(n) : (t = !0, u(n), i)
- };
- n.reject = n.resolver.reject = function(n) {
- return t ? o(new r(n)) : (t = !0, f(n), i)
- };
- n.notify = n.resolver.notify = function(n) {
- return e(n), n
- }
- }
- var n, i, t;
- return n = {
- promise: u,
- resolve: u,
- reject: u,
- notify: u,
- resolver: {
- resolve: u,
- reject: u,
- notify: u
- }
- }, n.promise = i = e(f), n
- }
- function w(n, t) {
- for (var i = 0; i < n.length; i++) n[i](t)
- }
- function pt(n, t) {
- if (t === n) return new r(new TypeError);
- if (t instanceof f) return t;
- try {
- var i = t === Object(t) && t.then;
- return typeof i == "function" ? wt(i, t) : new c(t)
- } catch (u) {
- return new r(u)
- }
- }
- function wt(n, t) {
- return e(function(i, r) {
- d(n, t, i, r)
- })
- }
- function c(n) {
- this.value = n
- }
- function r(n) {
- this.value = n
- }
- function b(n) {
- this.value = n
- }
- function bt(n, t) {
- function i() {
- t.fulfilled()
- }
- function r(n) {
- t.rejected(n)
- }
- n.then(i, r)
- }
- function rt(n) {
- return n && typeof n.then == "function"
- }
- function ut(n, i, r, u, f) {
- return t(n, function(n) {
- function o(r, u, f) {
- function y(n) {
- c(n)
- }
- function w(n) {
- h(n)
- }
- var o, v, s, a, h, c, l, e;
- if (l = n.length >>> 0, o = Math.max(0, Math.min(i, l)), s = [], v = l - o + 1, a = [], o)
- for (c = function(n) {
- a.push(n);
- --v || (h = c = p, u(a))
- }, h = function(n) {
- s.push(n);
- --o || (h = c = p, r(s))
- }, e = 0; e < l; ++e) e in n && t(n[e], w, y, f);
- else r(s)
- }
- return e(o).then(r, u, f)
- })
- }
- function kt(n, t, i, r) {
- function u(n) {
- return t ? t(n[0]) : n[0]
- }
- return ut(n, 1, u, i, r)
- }
- function ft(n, t, i, r) {
- return l(n, p).then(t, i, r)
- }
- function dt() {
- return l(arguments, p)
- }
- function gt(n) {
- return l(n, et, ot)
- }
- function ni(n, t) {
- return l(n, t)
- }
- function l(n, i, r) {
- return t(n, function(n) {
- function u(u, f, e) {
- function l(n, o) {
- t(n, i, r).then(function(n) {
- s[o] = n;
- --h || u(s)
- }, f, e)
- }
- var s, c, h, o;
- if (h = c = n.length >>> 0, s = [], !h) {
- u(s);
- return
- }
- for (o = 0; o < c; o++) o in n ? l(n[o], o) : --h
- }
- return new f(u)
- })
- }
- function ti(n, i) {
- var r = d(k, arguments, 1);
- return t(n, function(n) {
- var u;
- return u = n.length, r[0] = function(n, r, f) {
- return t(n, function(n) {
- return t(r, function(t) {
- return i(n, t, f, u)
- })
- })
- }, st.apply(n, r)
- })
- }
- function et(n) {
- return {
- state: "fulfilled",
- value: n
- }
- }
- function ot(n) {
- return {
- state: "rejected",
- reason: n
- }
- }
- function ii() {
- return {
- state: "pending"
- }
- }
- function y(n) {
- v.push(n) === 1 && s(lt)
- }
- function lt() {
- w(v);
- v = []
- }
- function p(n) {
- return n
- }
- function ri(n) {
- typeof h.reportUnhandled == "function" ? h.reportUnhandled() : y(function() {
- throw n;
- });
- throw n;
- }
- t.promise = e;
- t.resolve = o;
- t.reject = vt;
- t.defer = yt;
- t.join = dt;
- t.all = ft;
- t.map = ni;
- t.reduce = ti;
- t.settle = gt;
- t.any = kt;
- t.some = ut;
- t.isPromise = rt;
- t.isPromiseLike = rt;
- i = f.prototype;
- i.then = function(n, t, i) {
- var r = this;
- return new f(function(u, f, e) {
- r._when(u, e, n, t, i)
- }, this._status && this._status.observed())
- };
- i["catch"] = i.otherwise = function(n) {
- return this.then(u, n)
- };
- i["finally"] = i.ensure = function(n) {
- function t() {
- return o(n())
- }
- return typeof n == "function" ? this.then(t, t)["yield"](this) : this
- };
- i.done = function(n, t) {
- this.then(n, t)["catch"](ri)
- };
- i["yield"] = function(n) {
- return this.then(function() {
- return n
- })
- };
- i.tap = function(n) {
- return this.then(n)["yield"](this)
- };
- i.spread = function(n) {
- return this.then(function(t) {
- return ft(t, function(t) {
- return n.apply(u, t)
- })
- })
- };
- i.always = function(n, t) {
- return this.then(n, n, t)
- };
- a = Object.create || function(n) {
- function t() {}
- return t.prototype = n, new t
- };
- c.prototype = a(i);
- c.prototype.inspect = function() {
- return et(this.value)
- };
- c.prototype._when = function(n, t, i) {
- try {
- n(typeof i == "function" ? i(this.value) : this.value)
- } catch (u) {
- n(new r(u))
- }
- };
- r.prototype = a(i);
- r.prototype.inspect = function() {
- return ot(this.value)
- };
- r.prototype._when = function(n, t, i, u) {
- try {
- n(typeof u == "function" ? u(this.value) : this)
- } catch (f) {
- n(new r(f))
- }
- };
- b.prototype = a(i);
- b.prototype._when = function(n, t, i, r, u) {
- try {
- t(typeof u == "function" ? u(this.value) : this.value)
- } catch (f) {
- t(f)
- }
- };
- var i, a, st, k, d, s, v, g, nt, tt, h, ht, it, ct, u;
- if (it = n, v = [], h = typeof console != "undefined" ? console : t, typeof process == "object" && process.nextTick) s = process.nextTick;
- else if (ct = typeof MutationObserver == "function" && MutationObserver || typeof WebKitMutationObserver == "function" && WebKitMutationObserver) s = function(n, t, i) {
- var r = n.createElement("div");
- return new t(i).observe(r, {
- attributes: !0
- }),
- function() {
- r.setAttribute("x", "x")
- }
- }(document, ct, lt);
- else try {
- s = it("vertx").runOnLoop || it("vertx").runOnContext
- } catch (ui) {
- ht = setTimeout;
- s = function(n) {
- ht(n, 0)
- }
- }
- return g = Function.prototype, nt = g.call, d = g.bind ? nt.bind(nt) : function(n, t) {
- return n.apply(t, k.call(arguments, 2))
- }, tt = [], k = tt.slice, st = tt.reduce || function(n) {
- var i, u, r, f, t;
- if (t = 0, i = Object(this), f = i.length >>> 0, u = arguments, u.length <= 1)
- for (;;) {
- if (t in i) {
- r = i[t++];
- break
- }
- if (++t >= f) throw new TypeError;
- } else r = u[1];
- for (; t < f; ++t) t in i && (r = n(r, i[t], t, i));
- return r
- }, t
- })
- })(typeof define == "function" && define.amd ? define : function(n) {
- module.exports = n(require)
- });
- CryptoJS = CryptoJS || function(n, t) {
- var u = {},
- f = u.lib = {},
- i = f.Base = function() {
- function n() {}
- return {
- extend: function(t) {
- n.prototype = this;
- var i = new n;
- return t && i.mixIn(t), i.hasOwnProperty("init") || (i.init = function() {
- i.$super.init.apply(this, arguments)
- }), i.init.prototype = i, i.$super = this, i
- },
- create: function() {
- var n = this.extend();
- return n.init.apply(n, arguments), n
- },
- init: function() {},
- mixIn: function(n) {
- for (var t in n) n.hasOwnProperty(t) && (this[t] = n[t]);
- n.hasOwnProperty("toString") && (this.toString = n.toString)
- },
- clone: function() {
- return this.init.prototype.extend(this)
- }
- }
- }(),
- r = f.WordArray = i.extend({
- init: function(n, i) {
- n = this.words = n || [];
- this.sigBytes = i != t ? i : n.length * 4
- },
- toString: function(n) {
- return (n || h).stringify(this)
- },
- concat: function(n) {
- var i = this.words,
- r = n.words,
- u = this.sigBytes,
- f = n.sigBytes,
- e, t;
- if (this.clamp(), u % 4)
- for (t = 0; t < f; t++) e = r[t >>> 2] >>> 24 - t % 4 * 8 & 255, i[u + t >>> 2] |= e << 24 - (u + t) % 4 * 8;
- else if (r.length > 65535)
- for (t = 0; t < f; t += 4) i[u + t >>> 2] = r[t >>> 2];
- else i.push.apply(i, r);
- return this.sigBytes += f, this
- },
- clamp: function() {
- var i = this.words,
- t = this.sigBytes;
- i[t >>> 2] &= 4294967295 << 32 - t % 4 * 8;
- i.length = n.ceil(t / 4)
- },
- clone: function() {
- var n = i.clone.call(this);
- return n.words = this.words.slice(0), n
- },
- random: function(t) {
- for (var i = [], u = 0; u < t; u += 4) i.push(n.random() * 4294967296 | 0);
- return new r.init(i, t)
- }
- }),
- e = u.enc = {},
- h = e.Hex = {
- stringify: function(n) {
- for (var r, u = n.words, f = n.sigBytes, i = [], t = 0; t < f; t++) r = u[t >>> 2] >>> 24 - t % 4 * 8 & 255, i.push((r >>> 4).toString(16)), i.push((r & 15).toString(16));
- return i.join("")
- },
- parse: function(n) {
- for (var i = n.length, u = [], t = 0; t < i; t += 2) u[t >>> 3] |= parseInt(n.substr(t, 2), 16) << 24 - t % 8 * 4;
- return new r.init(u, i / 2)
- }
- },
- o = e.Latin1 = {
- stringify: function(n) {
- for (var r, u = n.words, f = n.sigBytes, i = [], t = 0; t < f; t++) r = u[t >>> 2] >>> 24 - t % 4 * 8 & 255, i.push(String.fromCharCode(r));
- return i.join("")
- },
- parse: function(n) {
- for (var i = n.length, u = [], t = 0; t < i; t++) u[t >>> 2] |= (n.charCodeAt(t) & 255) << 24 - t % 4 * 8;
- return new r.init(u, i)
- }
- },
- c = e.Utf8 = {
- stringify: function(n) {
- try {
- return decodeURIComponent(escape(o.stringify(n)))
- } catch (t) {
- throw new Error("Malformed UTF-8 data");
- }
- },
- parse: function(n) {
- return o.parse(unescape(encodeURIComponent(n)))
- }
- },
- s = f.BufferedBlockAlgorithm = i.extend({
- reset: function() {
- this._data = new r.init;
- this._nDataBytes = 0
- },
- _append: function(n) {
- typeof n == "string" && (n = c.parse(n));
- this._data.concat(n);
- this._nDataBytes += n.sigBytes
- },
- _process: function(t) {
- var e = this._data,
- h = e.words,
- c = e.sigBytes,
- o = this.blockSize,
- a = o * 4,
- u = c / a,
- i, s, f, l;
- if (u = t ? n.ceil(u) : n.max((u | 0) - this._minBufferSize, 0), i = u * o, s = n.min(i * 4, c), i) {
- for (f = 0; f < i; f += o) this._doProcessBlock(h, f);
- l = h.splice(0, i);
- e.sigBytes -= s
- }
- return new r.init(l, s)
- },
- clone: function() {
- var n = i.clone.call(this);
- return n._data = this._data.clone(), n
- },
- _minBufferSize: 0
- }),
- a = f.Hasher = s.extend({
- cfg: i.extend(),
- init: function(n) {
- this.cfg = this.cfg.extend(n);
- this.reset()
- },
- reset: function() {
- s.reset.call(this);
- this._doReset()
- },
- update: function(n) {
- return this._append(n), this._process(), this
- },
- finalize: function(n) {
- n && this._append(n);
- return this._doFinalize()
- },
- blockSize: 16,
- _createHelper: function(n) {
- return function(t, i) {
- return new n.init(i).finalize(t)
- }
- },
- _createHmacHelper: function(n) {
- return function(t, i) {
- return new l.HMAC.init(n, i).finalize(t)
- }
- }
- }),
- l = u.algo = {};
- return u
- }(Math),
- function() {
- var n = CryptoJS,
- t = n.lib,
- i = t.WordArray,
- r = n.enc,
- u = r.Base64 = {
- stringify: function(n) {
- var u = n.words,
- e = n.sigBytes,
- o = this._map,
- i, t, r, f;
- for (n.clamp(), i = [], t = 0; t < e; t += 3) {
- var s = u[t >>> 2] >>> 24 - t % 4 * 8 & 255,
- h = u[t + 1 >>> 2] >>> 24 - (t + 1) % 4 * 8 & 255,
- c = u[t + 2 >>> 2] >>> 24 - (t + 2) % 4 * 8 & 255,
- l = s << 16 | h << 8 | c;
- for (r = 0; r < 4 && t + r * .75 < e; r++) i.push(o.charAt(l >>> 6 * (3 - r) & 63))
- }
- if (f = o.charAt(64), f)
- while (i.length % 4) i.push(f);
- return i.join("")
- },
- parse: function(n) {
- var o = n.length,
- u = this._map,
- s = u.charAt(64),
- f, e, r, t, h, c;
- for (s && (f = n.indexOf(s), f != -1 && (o = f)), e = [], r = 0, t = 0; t < o; t++) t % 4 && (h = u.indexOf(n.charAt(t - 1)) << t % 4 * 2, c = u.indexOf(n.charAt(t)) >>> 6 - t % 4 * 2, e[r >>> 2] |= (h | c) << 24 - r % 4 * 8, r++);
- return i.create(e, r)
- },
- _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
- }
- }(),
- function() {
- var n = CryptoJS,
- t = n.lib,
- i = t.Base,
- r = n.enc,
- u = r.Utf8,
- f = n.algo,
- e = f.HMAC = i.extend({
- init: function(n, t) {
- var r, f, i;
- n = this._hasher = new n.init;
- typeof t == "string" && (t = u.parse(t));
- r = n.blockSize;
- f = r * 4;
- t.sigBytes > f && (t = n.finalize(t));
- t.clamp();
- var e = this._oKey = t.clone(),
- o = this._iKey = t.clone(),
- s = e.words,
- h = o.words;
- for (i = 0; i < r; i++) s[i] ^= 1549556828, h[i] ^= 909522486;
- e.sigBytes = o.sigBytes = f;
- this.reset()
- },
- reset: function() {
- var n = this._hasher;
- n.reset();
- n.update(this._iKey)
- },
- update: function(n) {
- return this._hasher.update(n), this
- },
- finalize: function(n) {
- var t = this._hasher,
- i = t.finalize(n);
- return t.reset(), t.finalize(this._oKey.clone().concat(i))
- }
- })
- }(),
- function(n) {
- var i = CryptoJS,
- f = i.lib,
- s = f.WordArray,
- r = f.Hasher,
- h = i.algo,
- e = [],
- o = [],
- t, u;
- (function() {
- function u(t) {
- for (var r = n.sqrt(t), i = 2; i <= r; i++)
- if (!(t % i)) return !1;
- return !0
- }
- function r(n) {
- return (n - (n | 0)) * 4294967296 | 0
- }
- for (var i = 2, t = 0; t < 64;) u(i) && (t < 8 && (e[t] = r(n.pow(i, 1 / 2))), o[t] = r(n.pow(i, 1 / 3)), t++), i++
- })();
- t = [];
- u = h.SHA256 = r.extend({
- _doReset: function() {
- this._hash = new s.init(e.slice(0))
- },
- _doProcessBlock: function(n, i) {
- for (var r = this._hash.words, f = r[0], s = r[1], h = r[2], y = r[3], e = r[4], a = r[5], v = r[6], p = r[7], u = 0; u < 64; u++) {
- if (u < 16) t[u] = n[i + u] | 0;
- else {
- var c = t[u - 15],
- b = (c << 25 | c >>> 7) ^ (c << 14 | c >>> 18) ^ c >>> 3,
- l = t[u - 2],
- k = (l << 15 | l >>> 17) ^ (l << 13 | l >>> 19) ^ l >>> 10;
- t[u] = b + t[u - 7] + k + t[u - 16]
- }
- var d = e & a ^ ~e & v,
- g = f & s ^ f & h ^ s & h,
- nt = (f << 30 | f >>> 2) ^ (f << 19 | f >>> 13) ^ (f << 10 | f >>> 22),
- tt = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25),
- w = p + tt + d + o[u] + t[u],
- it = nt + g;
- p = v;
- v = a;
- a = e;
- e = y + w | 0;
- y = h;
- h = s;
- s = f;
- f = w + it | 0
- }
- r[0] = r[0] + f | 0;
- r[1] = r[1] + s | 0;
- r[2] = r[2] + h | 0;
- r[3] = r[3] + y | 0;
- r[4] = r[4] + e | 0;
- r[5] = r[5] + a | 0;
- r[6] = r[6] + v | 0;
- r[7] = r[7] + p | 0
- },
- _doFinalize: function() {
- var r = this._data,
- t = r.words,
- u = this._nDataBytes * 8,
- i = r.sigBytes * 8;
- return t[i >>> 5] |= 128 << 24 - i % 32, t[(i + 64 >>> 9 << 4) + 14] = n.floor(u / 4294967296), t[(i + 64 >>> 9 << 4) + 15] = u, r.sigBytes = t.length * 4, this._process(), this._hash
- },
- clone: function() {
- var n = r.clone.call(this);
- return n._hash = this._hash.clone(), n
- }
- });
- i.SHA256 = r._createHelper(u);
- i.HmacSHA256 = r._createHmacHelper(u)
- }(Math),
- function() {
- var n = CryptoJS,
- i = n.lib,
- r = i.Base,
- u = i.WordArray,
- t = n.algo,
- f = t.SHA1,
- e = t.HMAC,
- o = t.PBKDF2 = r.extend({
- cfg: r.extend({
- keySize: 4,
- hasher: f,
- iterations: 1
- }),
- init: function(n) {
- this.cfg = this.cfg.extend(n)
- },
- compute: function(n, t) {
- for (var s = this.cfg, r = e.create(s.hasher, n), f = u.create(), l = u.create([1]), p = f.words, w = l.words, a = s.keySize, b = s.iterations, o, c, y, i; p.length < a;) {
- o = r.update(t).finalize(l);
- r.reset();
- var v = o.words,
- k = v.length,
- h = o;
- for (c = 1; c < b; c++)
- for (h = r.finalize(h), r.reset(), y = h.words, i = 0; i < k; i++) v[i] ^= y[i];
- f.concat(o);
- w[0]++
- }
- return f.sigBytes = a * 4, f
- }
- });
- n.PBKDF2 = function(n, t, i) {
- return o.create(i).compute(n, t)
- }
- }();
- /** @license MIT License (c) 2011-2013 Copyright Tavendo GmbH. */
- AUTOBAHNJS_VERSION = "?.?.?";
- global = this,
- function(n, t) {
- typeof define == "function" && define.amd ? define(["when"], function(i) {
- return n.ab = t(n, i)
- }) : typeof exports != "undefined" ? typeof module != "undefined" && module.exports && (exports = module.exports = t(n, n.when)) : n.ab = t(n, n.when)
- }(global, function(n, t) {
- "use strict";
- var i = {};
- return i._version = AUTOBAHNJS_VERSION,
- function() {
- Array.prototype.indexOf || (Array.prototype.indexOf = function(n) {
- var u, r, t, i;
- if (this === null) throw new TypeError;
- if ((u = new Object(this), r = u.length >>> 0, r === 0) || (t = 0, arguments.length > 0 && (t = Number(arguments[1]), t !== t ? t = 0 : t !== 0 && t !== Infinity && t !== -Infinity && (t = (t > 0 || -1) * Math.floor(Math.abs(t)))), t >= r)) return -1;
- for (i = t >= 0 ? t : Math.max(r - Math.abs(t), 0); i < r; i++)
- if (i in u && u[i] === n) return i;
- return -1
- });
- Array.prototype.forEach || (Array.prototype.forEach = function(n, t) {
- var u, i, r, f, e;
- if (this === null) throw new TypeError(" this is null or not defined");
- if (r = new Object(this), f = r.length >>> 0, {}.toString.call(n) !== "[object Function]") throw new TypeError(n + " is not a function");
- for (t && (u = t), i = 0; i < f;) i in r && (e = r[i], n.call(u, e, i, r)), i++
- })
- }(), i._sliceUserAgent = function(n, t, i) {
- var s = [],
- r = navigator.userAgent,
- h = r.indexOf(n),
- f = r.indexOf(t, h),
- e, o, u;
- for (f < 0 && (f = r.length), e = r.slice(h, f).split(i), o = e[1].split("."), u = 0; u < o.length; ++u) s.push(parseInt(o[u], 10));
- return {
- name: e[0],
- version: s
- }
- }, i.getBrowser = function() {
- var n = navigator.userAgent;
- return n.indexOf("Chrome") > -1 ? i._sliceUserAgent("Chrome", " ", "/") : n.indexOf("Safari") > -1 ? i._sliceUserAgent("Safari", " ", "/") : n.indexOf("Firefox") > -1 ? i._sliceUserAgent("Firefox", " ", "/") : n.indexOf("MSIE") > -1 ? i._sliceUserAgent("MSIE", ";", " ") : null
- }, i.getServerUrl = function(t, i) {
- if (n.location.protocol === "file:") return i ? i : "ws://127.0.0.1/ws";
- var r = n.location.protocol === "https:" ? "wss://" : "ws://",
- u = n.location.port !== "" ? ":" + n.location.port : "",
- f = t ? t : "ws";
- return r + n.location.hostname + u + "/" + f
- }, i.browserNotSupportedMessage = "Browser does not support WebSockets (RFC6455)", i.deriveKey = function(n, t) {
- if (t && t.salt) {
- var i = t.salt,
- r = t.keylen || 32,
- u = t.iterations || 1e4,
- f = CryptoJS.PBKDF2(n, i, {
- keySize: r / 4,
- iterations: u,
- hasher: CryptoJS.algo.SHA256
- });
- return f.toString(CryptoJS.enc.Base64)
- }
- return n
- }, i._idchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", i._idlen = 16, i._subprotocol = "wamp", i._newid = function() {
- for (var n = "", t = 0; t < i._idlen; t += 1) n += i._idchars.charAt(Math.floor(Math.random() * i._idchars.length));
- return n
- }, i._newidFast = function() {
- return Math.random().toString(36)
- }, i.log = function() {
- if (arguments.length > 1) {
- console.group("Log Item");
- for (var n = 0; n < arguments.length; n += 1) console.log(arguments[n]);
- console.groupEnd()
- } else console.log(arguments[0])
- }, i._debugrpc = !1, i._debugpubsub = !1, i._debugws = !1, i._debugconnect = !1, i.debug = function(t, r, u) {
- if ("console" in n) i._debugrpc = t, i._debugpubsub = t, i._debugws = r, i._debugconnect = u;
- else throw "browser does not support console object";
- }, i.version = function() {
- return i._version
- }, i.PrefixMap = function() {
- var n = this;
- n._index = {};
- n._rindex = {}
- }, i.PrefixMap.prototype.get = function(n) {
- var t = this;
- return t._index[n]
- }, i.PrefixMap.prototype.set = function(n, t) {
- var i = this;
- i._index[n] = t;
- i._rindex[t] = n
- }, i.PrefixMap.prototype.setDefault = function(n) {
- var t = this;
- t._index[""] = n;
- t._rindex[n] = ""
- }, i.PrefixMap.prototype.remove = function(n) {
- var t = this,
- i = t._index[n];
- i && (delete t._index[n], delete t._rindex[i])
- }, i.PrefixMap.prototype.resolve = function(n, t) {
- var u = this,
- i = n.indexOf(":"),
- r;
- return i >= 0 && (r = n.substring(0, i), u._index[r]) ? u._index[r] + n.substring(i + 1) : t === !0 ? n : null
- }, i.PrefixMap.prototype.shrink = function(n, t) {
- for (var u, r, f = this, i = n.length; i > 0; i -= 1)
- if (u = n.substring(0, i), r = f._rindex[u], r) return r + ":" + n.substring(i);
- return t === !0 ? n : null
- }, i._MESSAGE_TYPEID_WELCOME = 0, i._MESSAGE_TYPEID_PREFIX = 1, i._MESSAGE_TYPEID_CALL = 2, i._MESSAGE_TYPEID_CALL_RESULT = 3, i._MESSAGE_TYPEID_CALL_ERROR = 4, i._MESSAGE_TYPEID_SUBSCRIBE = 5, i._MESSAGE_TYPEID_UNSUBSCRIBE = 6, i._MESSAGE_TYPEID_PUBLISH = 7, i._MESSAGE_TYPEID_EVENT = 8, i.CONNECTION_CLOSED = 0, i.CONNECTION_LOST = 1, i.CONNECTION_RETRIES_EXCEEDED = 2, i.CONNECTION_UNREACHABLE = 3, i.CONNECTION_UNSUPPORTED = 4, i.CONNECTION_UNREACHABLE_SCHEDULED_RECONNECT = 5, i.CONNECTION_LOST_SCHEDULED_RECONNECT = 6, i.Deferred = t.defer, i._construct = function(t, i) {
- return "WebSocket" in n ? i ? new WebSocket(t, i) : new WebSocket(t) : "MozWebSocket" in n ? i ? new MozWebSocket(t, i) : new MozWebSocket(t) : null
- }, i.Session = function(n, t, r, u) {
- var f = this;
- if (f._wsuri = n, f._options = u, f._websocket_onopen = t, f._websocket_onclose = r, f._websocket = null, f._websocket_connected = !1, f._session_id = null, f._wamp_version = null, f._server = null, f._calls = {}, f._subscriptions = {}, f._prefixes = new i.PrefixMap, f._txcnt = 0, f._rxcnt = 0, f._websocket = f._options && f._options.skipSubprotocolAnnounce ? i._construct(f._wsuri) : i._construct(f._wsuri, [i._subprotocol]), !f._websocket) {
- if (r !== undefined) {
- r(i.CONNECTION_UNSUPPORTED);
- return
- }
- throw i.browserNotSupportedMessage;
- }
- f._websocket.onmessage = function(n) {
- var t, r, h, e, c, s, v, y, p, w;
- if (i._debugws && (f._rxcnt += 1, console.group("WS Receive"), console.info(f._wsuri + " [" + f._session_id + "]"), console.log(f._rxcnt), console.log(n.data), console.groupEnd()), t = JSON.parse(n.data), t[1] in f._calls) {
- if (t[0] === i._MESSAGE_TYPEID_CALL_RESULT) {
- if (r = f._calls[t[1]], h = t[2], i._debugrpc && r._ab_callobj !== undefined) {
- for (console.group("WAMP Call", r._ab_callobj[2]), console.timeEnd(r._ab_tid), console.group("Arguments"), e = 3; e < r._ab_callobj.length; e += 1)
- if (c = r._ab_callobj[e], c !== undefined) console.log(c);
- else break;
- console.groupEnd();
- console.group("Result");
- console.log(h);
- console.groupEnd();
- console.groupEnd()
- }
- r.resolve(h)
- } else if (t[0] === i._MESSAGE_TYPEID_CALL_ERROR) {
- var u = f._calls[t[1]],
- l = t[2],
- a = t[3],
- o = t[4];
- if (i._debugrpc && u._ab_callobj !== undefined) {
- for (console.group("WAMP Call", u._ab_callobj[2]), console.timeEnd(u._ab_tid), console.group("Arguments"), s = 3; s < u._ab_callobj.length; s += 1)
- if (v = u._ab_callobj[s], v !== undefined) console.log(v);
- else break;
- console.groupEnd();
- console.group("Error");
- console.log(l);
- console.log(a);
- o !== undefined && console.log(o);
- console.groupEnd();
- console.groupEnd()
- }
- o !== undefined ? u.reject({
- uri: l,
- desc: a,
- detail: o
- }) : u.reject({
- uri: l,
- desc: a
- })
- }
- delete f._calls[t[1]]
- } else if (t[0] === i._MESSAGE_TYPEID_EVENT) y = f._prefixes.resolve(t[1], !0), y in f._subscriptions && (p = t[1], w = t[2], i._debugpubsub && (console.group("WAMP Event"), console.info(f._wsuri + " [" + f._session_id + "]"), console.log(p), console.log(w), console.groupEnd()), f._subscriptions[y].forEach(function(n) {
- n(p, w)
- }));
- else if (t[0] === i._MESSAGE_TYPEID_WELCOME)
- if (f._session_id === null) f._session_id = t[1], f._wamp_version = t[2], f._server = t[3], (i._debugrpc || i._debugpubsub) && (console.group("WAMP Welcome"), console.info(f._wsuri + " [" + f._session_id + "]"), console.log(f._wamp_version), console.log(f._server), console.groupEnd()), f._websocket_onopen !== null && f._websocket_onopen();
- else throw "protocol error (welcome message received more than once)";
- };
- f._websocket.onopen = function() {
- if (f._websocket.protocol !== i._subprotocol)
- if (typeof f._websocket.protocol == "undefined") i._debugws && (console.group("WS Warning"), console.info(f._wsuri), console.log("WebSocket object has no protocol attribute: WAMP subprotocol check skipped!"), console.groupEnd());
- else if (f._options && f._options.skipSubprotocolCheck) i._debugws && (console.group("WS Warning"), console.info(f._wsuri), console.log("Server does not speak WAMP, but subprotocol check disabled by option!"), console.log(f._websocket.protocol), console.groupEnd());
- else {
- f._websocket.close(1e3, "server does not speak WAMP");
- throw "server does not speak WAMP (but '" + f._websocket.protocol + "' !)";
- }
- i._debugws && (console.group("WAMP Connect"), console.info(f._wsuri), console.log(f._websocket.protocol), console.groupEnd());
- f._websocket_connected = !0
- };
- f._websocket.onerror = function() {};
- f._websocket.onclose = function(n) {
- i._debugws && (f._websocket_connected ? console.log("Autobahn connection to " + f._wsuri + " lost (code " + n.code + ", reason '" + n.reason + "', wasClean " + n.wasClean + ").") : console.log("Autobahn could not connect to " + f._wsuri + " (code " + n.code + ", reason '" + n.reason + "', wasClean " + n.wasClean + ")."));
- f._websocket_onclose !== undefined && (f._websocket_connected ? n.wasClean ? f._websocket_onclose(i.CONNECTION_CLOSED, "WS-" + n.code + ": " + n.reason) : f._websocket_onclose(i.CONNECTION_LOST) : f._websocket_onclose(i.CONNECTION_UNREACHABLE));
- f._websocket_connected = !1;
- f._wsuri = null;
- f._websocket_onopen = null;
- f._websocket_onclose = null;
- f._websocket = null
- };
- f.log = function() {
- f._options && "sessionIdent" in f._options ? console.group("WAMP Session '" + f._options.sessionIdent + "' [" + f._session_id + "]") : console.group("WAMP Session [" + f._session_id + "]");
- for (var n = 0; n < arguments.length; ++n) console.log(arguments[n]);
- console.groupEnd()
- }
- }, i.Session.prototype._send = function(t) {
- var r = this,
- u;
- if (!r._websocket_connected) throw "Autobahn not connected";
- switch (!0) {
- case n.Prototype && typeof top.root.__prototype_deleted == "undefined":
- case typeof t.toJSON == "function":
- u = t.toJSON();
- break;
- default:
- u = JSON.stringify(t)
- }
- r._websocket.send(u);
- r._txcnt += 1;
- i._debugws && (console.group("WS Send"), console.info(r._wsuri + " [" + r._session_id + "]"), console.log(r._txcnt), console.log(u), console.groupEnd())
- }, i.Session.prototype.close = function() {
- var n = this;
- n._websocket_connected && n._websocket.close()
- }, i.Session.prototype.sessionid = function() {
- var n = this;
- return n._session_id
- }, i.Session.prototype.wsuri = function() {
- var n = this;
- return n._wsuri
- }, i.Session.prototype.shrink = function(n, t) {
- var i = this;
- return t === undefined && (t = !0), i._prefixes.shrink(n, t)
- }, i.Session.prototype.resolve = function(n, t) {
- var i = this;
- return t === undefined && (t = !0), i._prefixes.resolve(n, t)
- }, i.Session.prototype.prefix = function(n, t) {
- var r = this,
- u;
- r._prefixes.set(n, t);
- (i._debugrpc || i._debugpubsub) && (console.group("WAMP Prefix"), console.info(r._wsuri + " [" + r._session_id + "]"), console.log(n), console.log(t), console.groupEnd());
- u = [i._MESSAGE_TYPEID_PREFIX, n, t];
- r._send(u)
- }, i.Session.prototype.call = function() {
- for (var t = this, n = new i.Deferred, r, e, u, f;;)
- if (r = i._newidFast(), !(r in t._calls)) break;
- for (t._calls[r] = n, e = t._prefixes.shrink(arguments[0], !0), u = [i._MESSAGE_TYPEID_CALL, r, e], f = 1; f < arguments.length; f += 1) u.push(arguments[f]);
- return t._send(u), i._debugrpc && (n._ab_callobj = u, n._ab_tid = t._wsuri + " [" + t._session_id + "][" + r + "]", console.time(n._ab_tid), console.info()), n.promise.then ? n.promise : n
- }, i.Session.prototype.subscribe = function(n, t) {
- var r = this,
- u = r._prefixes.resolve(n, !0),
- f, e;
- if (u in r._subscriptions || (i._debugpubsub && (console.group("WAMP Subscribe"), console.info(r._wsuri + " [" + r._session_id + "]"), console.log(n), console.log(t), console.groupEnd()), f = [i._MESSAGE_TYPEID_SUBSCRIBE, n], r._send(f), r._subscriptions[u] = []), e = r._subscriptions[u].indexOf(t), e === -1) r._subscriptions[u].push(t);
- else throw "callback " + t + " already subscribed for topic " + u;
- }, i.Session.prototype.unsubscribe = function(n, t) {
- var r = this,
- u = r._prefixes.resolve(n, !0),
- f, e, o;
- if (u in r._subscriptions) {
- if (t !== undefined)
- if (e = r._subscriptions[u].indexOf(t), e !== -1) f = t, r._subscriptions[u].splice(e, 1);
- else throw "no callback " + t + " subscribed on topic " + u;
- else f = r._subscriptions[u].slice(), r._subscriptions[u] = [];
- r._subscriptions[u].length === 0 && (delete r._subscriptions[u], i._debugpubsub && (console.group("WAMP Unsubscribe"), console.info(r._wsuri + " [" + r._session_id + "]"), console.log(n), console.log(f), console.groupEnd()), o = [i._MESSAGE_TYPEID_UNSUBSCRIBE, n], r._send(o))
- } else throw "not subscribed to topic " + u;
- }, i.Session.prototype.publish = function() {
- var o = this,
- t = arguments[0],
- r = arguments[1],
- f = null,
- n = null,
- e = null,
- u = null;
- if (arguments.length > 3) {
- if (!(arguments[2] instanceof Array)) throw "invalid argument type(s)";
- if (!(arguments[3] instanceof Array)) throw "invalid argument type(s)";
- n = arguments[2];
- e = arguments[3];
- u = [i._MESSAGE_TYPEID_PUBLISH, t, r, n, e]
- } else if (arguments.length > 2)
- if (typeof arguments[2] == "boolean") f = arguments[2], u = [i._MESSAGE_TYPEID_PUBLISH, t, r, f];
- else if (arguments[2] instanceof Array) n = arguments[2], u = [i._MESSAGE_TYPEID_PUBLISH, t, r, n];
- else throw "invalid argument type(s)";
- else u = [i._MESSAGE_TYPEID_PUBLISH, t, r];
- i._debugpubsub && (console.group("WAMP Publish"), console.info(o._wsuri + " [" + o._session_id + "]"), console.log(t), console.log(r), f !== null ? console.log(f) : n !== null && (console.log(n), e !== null && console.log(e)), console.groupEnd());
- o._send(u)
- }, i.Session.prototype.authreq = function(n, t) {
- return this.call("http://api.wamp.ws/procedure#authreq", n, t)
- }, i.Session.prototype.authsign = function(n, t) {
- return t || (t = ""), CryptoJS.HmacSHA256(n, t).toString(CryptoJS.enc.Base64)
- }, i.Session.prototype.auth = function(n) {
- return this.call("http://api.wamp.ws/procedure#auth", n)
- }, i._connect = function(t) {
- var r = new i.Session(t.wsuri, function() {
- t.connects += 1;
- t.retryCount = 0;
- t.onConnect(r)
- }, function(r, u) {
- var f = null;
- switch (r) {
- case i.CONNECTION_CLOSED:
- t.onHangup(r, "Connection was closed properly [" + u + "]");
- break;
- case i.CONNECTION_UNSUPPORTED:
- t.onHangup(r, "Browser does not support WebSocket.");
- break;
- case i.CONNECTION_UNREACHABLE:
- if (t.retryCount += 1, t.connects === 0) t.onHangup(r, "Connection could not be established.");
- else if (t.retryCount <= t.options.maxRetries)
- if (f = t.onHangup(i.CONNECTION_UNREACHABLE_SCHEDULED_RECONNECT, "Connection unreachable - scheduled reconnect to occur in " + t.options.retryDelay / 1e3 + " second(s) - attempt " + t.retryCount + " of " + t.options.maxRetries + ".", {
- delay: t.options.retryDelay,
- retries: t.retryCount,
- maxretries: t.options.maxRetries
- }), f) {
- i._debugconnect && console.log("Connection unreachable - retrying stopped by app");
- t.onHangup(i.CONNECTION_RETRIES_EXCEEDED, "Number of connection retries exceeded.")
- } else i._debugconnect && console.log("Connection unreachable - retrying (" + t.retryCount + ") .."), n.setTimeout(function() {
- i._connect(t)
- }, t.options.retryDelay);
- else t.onHangup(i.CONNECTION_RETRIES_EXCEEDED, "Number of connection retries exceeded.");
- break;
- case i.CONNECTION_LOST:
- if (t.retryCount += 1, t.retryCount <= t.options.maxRetries)
- if (f = t.onHangup(i.CONNECTION_LOST_SCHEDULED_RECONNECT, "Connection lost - scheduled " + t.retryCount + "th reconnect to occur in " + t.options.retryDelay / 1e3 + " second(s).", {
- delay: t.options.retryDelay,
- retries: t.retryCount,
- maxretries: t.options.maxRetries
- }), f) {
- i._debugconnect && console.log("Connection lost - retrying stopped by app");
- t.onHangup(i.CONNECTION_RETRIES_EXCEEDED, "Connection lost.")
- } else i._debugconnect && console.log("Connection lost - retrying (" + t.retryCount + ") .."), n.setTimeout(function() {
- i._connect(t)
- }, t.options.retryDelay);
- else t.onHangup(i.CONNECTION_RETRIES_EXCEEDED, "Connection lost.");
- break;
- default:
- throw "unhandled close code in ab._connect";
- }
- }, t.options)
- }, i.connect = function(n, t, r, u) {
- var f = {};
- if (f.wsuri = n, f.options = u ? u : {}, f.options.retryDelay === undefined && (f.options.retryDelay = 5e3), f.options.maxRetries === undefined && (f.options.maxRetries = 10), f.options.skipSubprotocolCheck === undefined && (f.options.skipSubprotocolCheck = !1), f.options.skipSubprotocolAnnounce === undefined && (f.options.skipSubprotocolAnnounce = !1), t) f.onConnect = t;
- else throw "onConnect handler required!";
- f.onHangup = r ? r : function(n, t, r) {
- i._debugconnect && console.log(n, t, r)
- };
- f.connects = 0;
- f.retryCount = 0;
- i._connect(f)
- }, i.launch = function(n, t, r) {
- i.connect(n.wsuri, function(r) {
- n.appkey && n.appkey !== "" ? r.authreq(n.appkey, n.appextra).then(function(u) {
- var f = null,
- e;
- typeof n.appsecret == "function" ? f = n.appsecret(u) : (e = i.deriveKey(n.appsecret, JSON.parse(u).authextra), f = r.authsign(u, e));
- r.auth(f).then(function() {
- t ? t(r) : i._debugconnect && r.log("Session opened.")
- }, r.log)
- }, r.log) : r.authreq().then(function() {
- r.auth().then(function() {
- t ? t(r) : i._debugconnect && r.log("Session opened.")
- }, r.log)
- }, r.log)
- }, function(n, t, u) {
- r ? r(n, t, u) : i._debugconnect && i.log("Session closed.", n, t, u)
- }, n.sessionConfig)
- }, i
- });
- ab._UA_FIREFOX = new RegExp(".*Firefox/([0-9+]*).*");
- ab._UA_CHROME = new RegExp(".*Chrome/([0-9+]*).*");
- ab._UA_CHROMEFRAME = new RegExp(".*chromeframe/([0-9]*).*");
- ab._UA_WEBKIT = new RegExp(".*AppleWebKit/([0-9+.]*)w*.*");
- ab._UA_WEBOS = new RegExp(".*webOS/([0-9+.]*)w*.*");
- ab._matchRegex = function(n, t) {
- var i = t.exec(n);
- return i ? i[1] : i
- };
- ab.lookupWsSupport = function() {
- var n = navigator.userAgent,
- t;
- return n.indexOf("MSIE") > -1 ? n.indexOf("MSIE 10") > -1 ? [!0, !0, !0] : n.indexOf("chromeframe") > -1 ? (t = parseInt(ab._matchRegex(n, ab._UA_CHROMEFRAME)), t >= 14) ? [!0, !1, !0] : [!1, !1, !1] : n.indexOf("MSIE 8") > -1 || n.indexOf("MSIE 9") > -1 ? [!0, !0, !0] : [!1, !1, !1] : n.indexOf("Firefox") > -1 ? (t = parseInt(ab._matchRegex(n, ab._UA_FIREFOX)), t) ? t >= 7 ? [!0, !1, !0] : t >= 3 ? [!0, !0, !0] : [!1, !1, !0] : [!1, !1, !0] : n.indexOf("Safari") > -1 && n.indexOf("Chrome") == -1 ? (t = ab._matchRegex(n, ab._UA_WEBKIT), t) ? n.indexOf("Windows") > -1 && t == "534+" ? [!0, !1, !0] : n.indexOf("Macintosh") > -1 && (t = t.replace("+", "").split("."), parseInt(t[0]) == 535 && parseInt(t[1]) >= 24 || parseInt(t[0]) > 535) ? [!0, !1, !0] : n.indexOf("webOS") > -1 ? (t = ab._matchRegex(n, ab._UA_WEBOS).split("."), parseInt(t[0]) == 2) ? [!1, !0, !0] : [!1, !1, !1] : [!0, !0, !0] : [!1, !1, !1] : n.indexOf("Chrome") > -1 ? (t = parseInt(ab._matchRegex(n, ab._UA_CHROME)), t) ? t >= 14 ? [!0, !1, !0] : t >= 4 ? [!0, !0, !0] : [!1, !1, !0] : [!1, !1, !1] : n.indexOf("Android") > -1 ? n.indexOf("Firefox") > -1 ? [!0, !1, !0] : n.indexOf("CrMo") > -1 ? [!0, !1, !0] : n.indexOf("Opera") > -1 ? [!1, !1, !0] : n.indexOf("CrMo") > -1 ? [!0, !0, !0] : [!1, !1, !1] : n.indexOf("iPhone") > -1 || n.indexOf("iPad") > -1 || n.indexOf("iPod") > -1 ? [!1, !1, !0] : [!1, !1, !1]
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement