PageSourceSearch

https://www.afa.com.ar/js/web/Sockets.js?v=1722026780

js afa.com.ar collected 2026-10-02 03:28:05 UTC 4,263 bytes, 142 lines download raw bytes

1
2class AfaSocket {
3
4    constructor( url, autoConnect, Params ){
5        this.socket         = null;
6        this.WaitingIO      = null;
7        this.socketStatus   = 0;
8        this.debug          = false;
9
10
11        this.eventoSocketReadyListeners = [];
12        this.eventoConnectListeners = [];
13        this.eventoDisConnectListeners = [];
14        this.eventoMessageListeners = [];
15        this.eventoErrorListeners = [];
16        
17        this.url = url || "ws://localhost:3000";
18
19        autoConnect = autoConnect ? true : false;
20
21        this.url = url;
22
23        this.Params = {
24            reconnectionDelay       : Params?.reconnectionDelay ?? 1000,
25            reconnectionDelayMax    : Params?.reconnectionDelayMax ?? 35000
26        };
27     
28        if( autoConnect ){
29            this.Connect();
30        }
31
32        
33    }
34
35    Connect(){
36
37        var _this = this;
38        if( this.checkLoaded() ){
39
40
41            this.socket = io( this.url , {
42                reconnectionDelay: this.Params.reconnectionDelay,  /* Establece el tiempo inicial de retraso entre intentos de conexión en 1 segundo (1000 milisegundos) */
43                reconnectionDelayMax: this.Params.reconnectionDelayMax  /* Establece el tiempo máximo de retraso entre intentos de conexión en 10 segundos (10000 milisegundos) */
44            });
45
46            this.socket.on('connect', ( message ) => {
47                if( _this.debug ){ console.log('Socket Conectado'); }
48                _this.socketStatus = 1;
49                _this.emitonConnect('CONECTADO');
50            });
51            this.socket.on('disconnect' , function(){
52                if( _this.debug ){ console.log('Socket Desconectado'); }
53                _this.socketStatus = 0;
54                _this.emitonDisconnect('DESCONECTADO')
55            });
56
57            this.socket.on('message', ( message ) => {
58                if( _this.debug ){ console.log('message' , message ); }
59                _this.emitonMessage( message );
60            });
61
62            this.socket.on('error', (error) => {
63                // Manejar el error de conexión aquí
64                if( _this.debug ){ console.error('Error de conexión a Socket.IO:', error); }
65                _this.emitonError( error );
66            });
67            
68            this.socket.on('connect_error', (error) => {
69                if( _this.debug ){ console.log('Error de conexión a Socket.IO:', error.message ); }
70                _this.emitonError( error );
71            });
72
73        }else{
74            var _this = this;
75            this.WaitingIO = setInterval(() => {
76                if( _this.checkLoaded() ){
77                    clearInterval( _this.WaitingIO ); 
78                    _this.Connect();
79                }
80            }, 1000);
81        }
82
83    }
84
85    
86
87    /* Listeners */
88    onReadySocket(listener) {
89        this.eventoSocketReadyListeners.push(listener);
90    }
91
92    onConnect(listener) {
93        this.eventoConnectListeners.push(listener);
94    }
95    onDisconnect(listener) {
96        this.eventoDisConnectListeners.push(listener);
97    }
98    onMessage(listener) {
99        this.eventoMessageListeners.push(listener);
100    }
101    onError(listener) {
102        this.eventoErrorListeners.push(listener);
103    }
104
105
106    
107
108    /* Emitter */
109    emitonReadySocket(data) {
110        this.eventoSocketReadyListeners.forEach(listener => listener(data));
111    }
112
113    emitonConnect(data) {
114        this.eventoConnectListeners.forEach(listener => listener(data));
115    }
116    emitonDisconnect(data) {
117        this.eventoDisConnectListeners.forEach(listener => listener(data));
118    }
119    emitonMessage(data) {
120        this.eventoMessageListeners.forEach(listener => listener(data));
121    }
122    emitonError(data) {
123        this.eventoErrorListeners.forEach(listener => listener(data));
124    }
125
126    
127
128    checkLoaded(){
129        if( this.debug ){ console.log('checkLoaded'); }
130        if (typeof io !== 'undefined') {
131            if( this.debug ){ console.log('Socket.io  ya esta disponible'); }
132            this.emitonReadySocket( 1 );
133            return true;
134        } else {
135            if( this.debug ){ console.error('Socket.io no está cargado.'); }
136            return false;
137        }
138    }
139};
140
141// const afasocket = new AfaSocket ( "ws://localhost:3000" , true );
142    

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.