UNPKG

awv3

Version:
76 lines (63 loc) 2.8 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = function (scope) { var signalR = _jquery2.default.signalR; function makeProxyCallback(hub, callback) { return function () { callback.apply(hub, _jquery2.default.makeArray(arguments)); }; } function registerHubProxies(instance, shouldSubscribe) { var key, hub, memberKey, memberValue, subscriptionMethod; for (key in instance) { if (instance.hasOwnProperty(key)) { hub = instance[key]; if (!hub.hubName) continue; if (shouldSubscribe) { subscriptionMethod = hub.on; } else { subscriptionMethod = hub.off; } for (memberKey in hub.client) { if (hub.client.hasOwnProperty(memberKey)) { memberValue = hub.client[memberKey]; if (!_jquery2.default.isFunction(memberValue)) continue; subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue)); } } } } } _jquery2.default.hubConnection.prototype.createHubProxies = function () { var proxies = {}; this.starting(function () { registerHubProxies(proxies, true); this._registerSubscribedHubs(); }).disconnected(function () { registerHubProxies(proxies, false); }); proxies.clientHub = this.createHubProxy('clientHub'); proxies.clientHub.client = {}; proxies.clientHub.server = { init: function init(debugging, PauseAllowed, TimeOut, Rebuild) { return proxies.clientHub.invoke.apply(proxies.clientHub, _jquery2.default.merge(["Init"], _jquery2.default.makeArray(arguments))); }, ping: function ping() { return proxies.clientHub.invoke.apply(proxies.clientHub, _jquery2.default.merge(["Ping"], _jquery2.default.makeArray(arguments))); }, send: function send(data) { return proxies.clientHub.invoke.apply(proxies.clientHub, _jquery2.default.merge(["Send"], _jquery2.default.makeArray(arguments))); } }; return proxies; }; scope._hub = _jquery2.default.hubConnection("/signalr", { useDefaultPath: false }); scope._proxy = scope._hub.createHubProxies(); }; var _jquery = require('jquery'); var _jquery2 = _interopRequireDefault(_jquery); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // Thank you very much, Microsoft ... window.jQuery = _jquery2.default;require('ms-signalr-client');