Skip to content

Instantly share code, notes, and snippets.

@bjornicus
Created August 28, 2017 18:43
Show Gist options
  • Save bjornicus/53317154dc12da7002a4a0d40ebd87e8 to your computer and use it in GitHub Desktop.
Save bjornicus/53317154dc12da7002a4a0d40ebd87e8 to your computer and use it in GitHub Desktop.
const socketIoClient = require('socket.io-client');
const client = socketIoClient(
'https://localhost',
{
query :
{
foo: false
},
autoconnect: false,
timeout : 30000,
reconnectionDelay : 30000,
reconnectionDelayMax : 30000,
reconnectionAttempts : 100,
transports: ['polling']
})
client.on('connect', x => console.log('connect: ' + x ));
client.on('connect_error', x => console.log('connect_error: ' + x ));
client.on('error', x => console.log('error: ' + x ));
client.on('disconnect', x => console.log('disconnect: ' + x ));
client.on('reconnect', x => console.log('reconnect: ' + x ));
client.on('reconnect_attempt', x => console.log('reconnect_attempt: ' + x ));
client.on('reconnecting', x => console.log('reconnecting: ' + x ));
client.on('reconnect_error', x => console.log('reconnect_error: ' + x ));
client.on('reconnect_failed', x => console.log('reconnect_failed: ' + x ));
client.on('ping', x => console.log('ping: '));
client.on('pong', x => console.log('pong: ' + x ));
client.on('message', m => console.log('message: ' + m));
client.on('myEvent', m => console.log('myEvent: ' + m));
client.open();
client.emit('myEvent', 'hello!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment