5***@qq.com
5***@qq.com
  • 发布:2016-09-13 18:03
  • 更新:2018-07-26 23:29
  • 阅读:1843

Hbulider开发的APP本质的web还是什么

分类:HBuilder

Hbulider开发的APP本质的web还是什么?
有没有人用 Hbulider对接过SignalR?现在APP端想实习Signal,但是SignalR有一部分必须文件是动态JS。
在项目上开发的没有问题。但是开发成APP的话,项目就独立开来了。这个部分动态JS要怎么实现引用了。
还有一个问题就是目前 我不确定这个JS通过 URL链接 是否有用。下面这个动态JS文件的内容

/*!  
 * ASP.NET SignalR JavaScript Library v2.2.1  
 * http://signalr.net/  
 *  
 * Copyright (c) .NET Foundation. All rights reserved.  
 * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.  
 *  
 */  

/// <reference path="..\..\SignalR.Client.JS\Scripts\jquery-1.6.4.js" />  
/// <reference path="jquery.signalR.js" />  
(function ($, window, undefined) {  
    /// <param name="$" type="jQuery" />  
    "use strict";  

    if (typeof ($.signalR) !== "function") {  
        throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");  
    }  

    var signalR = $.signalR;  

    function makeProxyCallback(hub, callback) {  
        return function () {  
            // Call the client hub method  
            callback.apply(hub, $.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)) {  
                    // Not a client hub  
                    continue;  
                }  

                if (shouldSubscribe) {  
                    // We want to subscribe to the hub events  
                    subscriptionMethod = hub.on;  
                } else {  
                    // We want to unsubscribe from the hub events  
                    subscriptionMethod = hub.off;  
                }  

                // Loop through all members on the hub and find client hub functions to subscribe/unsubscribe  
                for (memberKey in hub.client) {  
                    if (hub.client.hasOwnProperty(memberKey)) {  
                        memberValue = hub.client[memberKey];  

                        if (!$.isFunction(memberValue)) {  
                            // Not a client hub function  
                            continue;  
                        }  

                        subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue));  
                    }  
                }  
            }  
        }  
    }  

    $.hubConnection.prototype.createHubProxies = function () {  
        var proxies = {};  
        this.starting(function () {  
            // Register the hub proxies as subscribed  
            // (instance, shouldSubscribe)  
            registerHubProxies(proxies, true);  

            this._registerSubscribedHubs();  
        }).disconnected(function () {  
            // Unsubscribe all hub proxies when we "disconnect".  This is to ensure that we do not re-add functional call backs.  
            // (instance, shouldSubscribe)  
            registerHubProxies(proxies, false);  
        });  

        proxies['notificationCenter'] = this.createHubProxy('notificationCenter');   
        proxies['notificationCenter'].client = { };  
        proxies['notificationCenter'].server = {  
            login: function (username) {  
                return proxies['notificationCenter'].invoke.apply(proxies['notificationCenter'], $.merge(["Login"], $.makeArray(arguments)));  
             },  

            noticeManagerDeviceLock: function (manager, IMEI) {  
                return proxies['notificationCenter'].invoke.apply(proxies['notificationCenter'], $.merge(["NoticeManagerDeviceLock"], $.makeArray(arguments)));  
             },  

            noticeManagerDeviceOnline: function (manager, IMEI) {  
                return proxies['notificationCenter'].invoke.apply(proxies['notificationCenter'], $.merge(["NoticeManagerDeviceOnline"], $.makeArray(arguments)));  
             },  

            noticeManagerDeviceOutLine: function (manager, IMEI) {  
                return proxies['notificationCenter'].invoke.apply(proxies['notificationCenter'], $.merge(["NoticeManagerDeviceOutLine"], $.makeArray(arguments)));  
             },  

            noticeManagerDeviceUnLock: function (manager, IMEI) {  
                return proxies['notificationCenter'].invoke.apply(proxies['notificationCenter'], $.merge(["NoticeManagerDeviceUnLock"], $.makeArray(arguments)));  
             },  

            noticeManagerResult: function (manager, result) {  
                return proxies['notificationCenter'].invoke.apply(proxies['notificationCenter'], $.merge(["NoticeManagerResult"], $.makeArray(arguments)));  
             },  

            sendCommandToDevice: function (strIMEI, commandStr) {  
                return proxies['notificationCenter'].invoke.apply(proxies['notificationCenter'], $.merge(["SendCommandToDevice"], $.makeArray(arguments)));  
             }  
        };  

        return proxies;  
    };  

    signalR.hub = $.hubConnection("/signalr", { useDefaultPath: false });  
    $.extend(signalR, signalR.hub.createHubProxies());  

}(window.jQuery, window));

2016-09-13 18:03 负责人:无 分享
已邀请:
zhongpei

zhongpei - 1984

可以用,

该问题目前已经被锁定, 无法添加新回复