1'use strict'; 2(function () { 3 var socketIoWrapper = function (host) { 4 var params = { 5 'gcUniqId': window.gcUniqId, 6 'accountId': window.accountId, 7 'accountUserId': window.accountUserId, 8 'gcSessionId': window.gcSessionId, 9 }; 10 11 var socket = io.connect(host, { 12 transports: ['websocket'], 13 path: '/ws/websocket', 14 query: $.param(params) 15 }); 16 17 var channels = {}; 18 19 this.pageKey = encodeURI(location.pathname.replace(/\//gm, '_').replace(/_$/gm, '')); 20 21 this.getSocket = function () { 22 return socket; 23 }; 24 25 this.getChannels = function () { 26 return channels; 27 }; 28 29 this.subscribeChannel = function(channel, handler) { 30 if (!channels[channel]) { 31 socket.emit('join', { 32 channel: channel 33 }); 34 35 channels[channel] = {handler: handler}; 36 } 37 }; 38 39 this.unsubscribeChannel = function (channel) { 40 if (channels[channel]) { 41 socket.emit('leave', {channel: channel}); 42 43 delete channels[channel]; 44 } 45 }; 46 47 socket.on('message', function (data) { 48 49 var json = data.json; 50 var channel = json.channel; 51 52 if (undefined !== channels[channel]) { 53 channels[channel].handler(JSON.stringify(data), json); 54 } 55 }); 56 57 socket.on('reconnect', function () { 58 for (var i in channels) { 59 socket.emit('join', { 60 channel: i 61 }); 62 } 63 }); 64 }; 65 66 window.accountUserWebSocketConnection = new socketIoWrapper(window.webSocketHost); 67})();
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.