naderio / nativescript-socket.io

Fully-featured Socket.IO client implementation for NativeScript
The Unlicense
48 stars 21 forks source link

Reconnection #45

Closed NicoDino closed 3 years ago

NicoDino commented 6 years ago

Hi! thanks for the awesome plugin guys.

I have the following code, and I'd like to know which is the right way to handle reconnection. I've tried automatic reconnection without success, I'm going to try a manual reconnection now and I'd like to know the proper way to do it.

Cheers!

                   const options = {
                        android: {
                            reconnection: false,
                        }
                    };

                    this.socketIO = SocketIO.connect(SocketBaseURL + '/socket_' + this.socket._id, options);
                    this.socketIO.on('connect', (socket) => {
                        console.log('Socket connected...');
                    });
                    this.socketIO.on('disconnect', (socket) => {
                        console.log('Socket DISCONNECTED...');
                    });
                    this.socketIO.on('connect_error', (socket) => {
                        console.log('Trouble connecting...');
                    });