PageSourceSearch

https://alibaba33top.com/js/signalr/sr-client.js

js alibaba33top.com collected 2026-10-08 07:38:26 UTC 2,441 bytes, 68 lines download raw bytes

1/*
2* This javascript contains function that implement real-time communication
3*/
4var hubTimeoutId;
5var hubConn = $.hubConnection();
6var srHub; // signalr hub proxy
7var reconnInterval = 10000; // signalr interval for attempt to reconnect
8var connMaxRetry = 5;
9
10// initialize signalr hub connection
11function InitHubConnection(hubUrl, appId, srToken) {
12    var connRetry = 0;
13    hubConn.qs = { "appId": appId, "token": srToken};
14    hubConn.url = hubUrl + "/signalr";
15    srHub = hubConn.createHubProxy('jcmmHub');    
16    // upon connection started
17    hubConn.start().done(function () {
18        // do something
19    });
20   
21    // signalR connection state changed
22    // state.oldState | state.newState
23    // 0: 'connecting', 1: 'connected', 2: 'reconnecting', 4: 'disconnected'
24    hubConn.stateChanged(function (change) {
25        if (change.newState === $.signalR.connectionState.connecting) {
26            console.log("Connecting to hub.");            
27        }
28        else if (change.newState === $.signalR.connectionState.connected) {            
29            console.log("Connected to hub. Transport=" + hubConn.transport.name);
30        }
31        else if (change.newState === $.signalR.connectionState.reconnecting) {
32            console.log("Reconnecting to hub.");
33        }
34        else if (change.newState === $.signalR.connectionState.disconnected) {
35            if (hubConn.lastError) {
36                console.log("Disconnected. Reason: " + hubConn.lastError.message);
37            }
38            console.log("Connection to hub is failed.");
39            console.log( "#" + (connRetry + 1) + " attempt to reconnect to hub");
40            // retry signalR connection when disconnected from web server
41            if (connRetry < connMaxRetry) {
42                hubTimeoutId = setTimeout(function () {
43                    hubConn.start();
44                }, reconnInterval);
45                connRetry += 1;
46            }
47        };
48    });      
49
50    srHub.on('getUpdate', function (subject) {
51        switch(subject) {
52            case 'ga_script':
53                //GetGAScript();
54                break;
55            default:
56                // do nothing;
57                console.log("srHub: Invalid notification subject");
58        }        
59    });
60
61    // clear timer 
62    window.onbeforeunload = function () {
63        clearTimeout(hubTimeoutId);
64    };
65}
66
67
68

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.