1var abp = abp || {}; 2(function () { 3 4 // Check if SignalR is defined 5 if (!signalR) { 6 return; 7 } 8 9 // Create namespaces 10 abp.signalr = abp.signalr || {}; 11 abp.signalr.hubs = abp.signalr.hubs || {}; 12 13 // Configure the connection 14 function configureConnection(connection) { 15 // Set the common hub 16 abp.signalr.hubs.common = connection; 17 18 // Reconnect if hub disconnects 19 connection.onclose(function (e) { 20 if (e) { 21 abp.log.debug('Connection closed with error: ' + e); 22 } 23 else { 24 abp.log.debug('Disconnected'); 25 } 26 27 if (!abp.signalr.autoConnect) { 28 return; 29 } 30 31 setTimeout(function () { 32 connection.start(); 33 }, 5000); 34 }); 35 36 // Register to get notifications 37 connection.on('getNotification', function (notification) { 38 abp.event.trigger('abp.notifications.received', notification); 39 }); 40 } 41 42 // Connect to the server 43 abp.signalr.connect = function () { 44 var url = abp.signalr.url || (abp.appPath + 'signalr'); 45 46 // Start the connection. 47 startConnection(url, configureConnection) 48 .then(function (connection) { 49 abp.log.debug('Connected to SignalR server!'); //TODO: Remove log 50 abp.event.trigger('abp.signalr.connected'); 51 // Call the Register method on the hub. 52 connection.invoke('register').then(function () { 53 abp.log.debug('Registered to the SignalR server!'); //TODO: Remove log 54 }); 55 }) 56 .catch(function (error) { 57 abp.log.debug(error.message); 58 }); 59 }; 60 61 // Starts a connection with transport fallback - if the connection cannot be started using 62 // the webSockets transport the function will fallback to the serverSentEvents transport and 63 // if this does not work it will try longPolling. If the connection cannot be started using 64 // any of the available transports the function will return a rejected Promise. 65 function startConnection(url, configureConnection) { 66 if (abp.signalr.remoteServiceBaseUrl) { 67 url = abp.signalr.remoteServiceBaseUrl + url; 68 } 69 70 // Add query string: https://github.com/aspnet/SignalR/issues/680 71 if (abp.signalr.qs) { 72 url += (url.indexOf('?') == -1 ? '?' : '&') + abp.signalr.qs; 73 } 74 75 return function start(transport) { 76 abp.log.debug('Starting connection using ' + signalR.HttpTransportType[transport] + ' transport'); 77 var connection = new signalR.HubConnectionBuilder() 78 .withUrl(url, transport) 79 .build(); 80 if (configureConnection && typeof configureConnection === 'function') { 81 configureConnection(connection); 82 } 83 84 return connection.start() 85 .then(function () { 86 return connection; 87 }) 88 .catch(function (error) { 89 abp.log.debug('Cannot start the connection using ' + signalR.HttpTransportType[transport] + ' transport. ' + error.message); 90 if (transport !== signalR.HttpTransportType.LongPolling) { 91 return start(transport + 1); 92 } 93 94 return Promise.reject(error); 95 }); 96 }(signalR.HttpTransportType.WebSockets); 97 } 98 99 abp.signalr.startConnection = startConnection; 100 101 if (abp.signalr.autoConnect === undefined) { 102 abp.signalr.autoConnect = true; 103 } 104 105 if (abp.signalr.autoConnect && !abp.signalr.hubs.common) { 106 abp.signalr.connect(); 107 } 108 109})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.