connect()

Returns (Promise)

Returns a regular promise that resolves when is connected correctly or reject when having an error.

  1. .then(token) (String) Every client connected to the server have a unique token.
  2. .catch(error) (Mixed)

Examples

var server = synko.create({connector:synko.socketio});
server.connect()
  .then((token) => {
    console.log('Connected!! My token is:', token);
  })
  .catch((error) => {
    console.error('Error connecting to the server:', error);
  });