init() {

		this._super(...arguments);

		// Create a new storage instance so that
		// we can store and persist all session
		// authentication information.

		this.storage = new Storage();

		// Create a new poller for sending ping
		// requests in a repeated manner in order
		// to keep loadbalancing requests open.

		this.pinger = new Poller(60000);

		// Listen for changes to the local storage
		// authentication key, and reauthenticate
		// if the token changes from another tab.

		if (window && window.addEventListener) {

			window.addEventListener('storage', (e) => {
				if (e.key == key) {
					this.authenticate(e.newValue);
				}
			});

		}

		// Listen for invalidation events so that
		// we can decode the JWT contents in order
		// to store it in the JWT object.

		this.on('invalidated', function() {
			let t = this.get('token');
			this.set('jwt', JWT(t));
		});

		// Listen for authentication events so that
		// we can decode the JWT contents in order
		// to store it in the JWT object.

		this.on('authenticated', function() {
			let t = this.get('token');
			this.set('jwt', JWT(t));
		});

		// Next we setup the websocket connection
		// and listen for events on the socket,
		// specifying whether logging is enabled.

		this.ws = new Socket(this.config.url, this.config.opts, {
			log: this.get('storage.debug') === '*',
		});

		// When the connection is closed we
		// change the relevant properties
		// stop live queries, and trigger.

		this.ws.onclose = () => {

			this.pinger.clear();

			this.setProperties({
				events: A(),
				opened: false,
				closed: true,
				attempted: false,
				invalidated: false,
				authentcated: false,
			});

			this.trigger("closed");

		};

		// When the connection is opened we
		// change the relevant properties
		// open live queries, and trigger.

		this.ws.onopen = () => {

			this.pinger.start(this, () => {
				this._send(guid(), 'Ping');
			});

			this.setProperties({
				events: A(),
				opened: true,
				closed: false,
				attempted: false,
				invalidated: false,
				authentcated: false,
			});

			this.trigger("opened");

			this._attempt();

		};

		// When we receive a socket message
		// we process it. If it has an ID
		// then it is a query response.

		this.ws.onmessage = (e) => {
			let d = JSON.parse(e.data);
			if (d.id) {
				this.trigger(d.id, d);
			} else {
				this.trigger(d.method, d.params);
			}
		};

		// Open the websocket for the first
		// time. This will automatically
		// attempt to reconnect on failure.

		this.ws.open();

	}
// and connecting to the DB.
and connecting to the DB.
and connecting to the DB .
init() {
		this._super(...arguments);
		this.storage = new Storage();
		this.pinger = new Poller(60000);
		if (window && window.addEventListener) {
			window.addEventListener('storage', (e) => {
				if (e.key == key) {
					this.authenticate(e.newValue);
				}
			});
		}
		this.on('invalidated', function() {
			let t = this.get('token');
			this.set('jwt', JWT(t));
		});
		this.on('authenticated', function() {
			let t = this.get('token');
			this.set('jwt', JWT(t));
		});
		this.ws = new Socket(this.config.url, this.config.opts, {
			log: this.get('storage.debug') === '*',
		});
		this.ws.onclose = () => {
			this.pinger.clear();
			this.setProperties({
				events: A(),
				opened: false,
				closed: true,
				attempted: false,
				invalidated: false,
				authentcated: false,
			});
			this.trigger("closed");
		};
		this.ws.onopen = () => {
			this.pinger.start(this, () => {
				this._send(guid(), 'Ping');
			});
			this.setProperties({
				events: A(),
				opened: true,
				closed: false,
				attempted: false,
				invalidated: false,
				authentcated: false,
			});
			this.trigger("opened");
			this._attempt();
		};
		this.ws.onmessage = (e) => {
			let d = JSON.parse(e.data);
			if (d.id) {
				this.trigger(d.id, d);
			} else {
				this.trigger(d.method, d.params);
			}
		};
		this.ws.open();
	}
init ( ) { this . _super ( ... arguments ) ; this . storage = new Storage ( ) ; this . pinger = new Poller ( 60000 ) ; if ( window && window . addEventListener ) { window . addEventListener ( 'storage' , ( e ) => { if ( e . key == key ) { this . authenticate ( e . newValue ) ; } } ) ; } this . on ( 'invalidated' , function ( ) { let t = this . get ( 'token' ) ; this . set ( 'jwt' , JWT ( t ) ) ; } ) ; this . on ( 'authenticated' , function ( ) { let t = this . get ( 'token' ) ; this . set ( 'jwt' , JWT ( t ) ) ; } ) ; this . ws = new Socket ( this . config . url , this . config . opts , { log : this . get ( 'storage.debug' ) === '*' , } ) ; this . ws . onclose = ( ) => { this . pinger . clear ( ) ; this . setProperties ( { events : A ( ) , opened : false , closed : true , attempted : false , invalidated : false , authentcated : false , } ) ; this . trigger ( "closed" ) ; } ; this . ws . onopen = ( ) => { this . pinger . start ( this , ( ) => { this . _send ( guid ( ) , 'Ping' ) ; } ) ; this . setProperties ( { events : A ( ) , opened : true , closed : false , attempted : false , invalidated : false , authentcated : false , } ) ; this . trigger ( "opened" ) ; this . _attempt ( ) ; } ; this . ws . onmessage = ( e ) => { let d = JSON . parse ( e . data ) ; if ( d . id ) { this . trigger ( d . id , d ) ; } else { this . trigger ( d . method , d . params ) ; } } ; this . ws . open ( ) ; }
and connecting to the DB.
and connecting to the DB .
// Create a new storage instance so that // we can store and persist all session // authentication information. // Create a new poller for sending ping // requests in a repeated manner in order // to keep loadbalancing requests open. // Listen for changes to the local storage // authentication key, and reauthenticate // if the token changes from another tab. // Listen for invalidation events so that // we can decode the JWT contents in order // to store it in the JWT object. // Listen for authentication events so that // we can decode the JWT contents in order // to store it in the JWT object. // Next we setup the websocket connection // and listen for events on the socket, // specifying whether logging is enabled. // When the connection is closed we // change the relevant properties // stop live queries, and trigger. // When the connection is opened we // change the relevant properties // open live queries, and trigger. // When we receive a socket message // we process it. If it has an ID // then it is a query response. // Open the websocket for the first // time. This will automatically // attempt to reconnect on failure.