How to use sockjs-client

Comprehensive sockjs-client code examples:

How to use sockjs-client.OPEN:

1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
if (this.readyState === SockJS.CONNECTING) {
  if (this._transportTimeoutId) {
    clearTimeout(this._transportTimeoutId);
    this._transportTimeoutId = null;
  }
  this.readyState = SockJS.OPEN;
  this.transport = this._transport.transportName;
  this.dispatchEvent(new Event('open'));
  debug('connected', this.transport);
} else {

How to use sockjs-client.CONNECTING:

776
777
778
779
780
781
782
783
784
785
if (arguments.length < 1) {
  throw new TypeError("Failed to construct 'SockJS: 1 argument required, but only 0 present");
}
EventTarget.call(this);

this.readyState = SockJS.CONNECTING;
this.extensions = '';
this.protocol = '';

// non-standard extension

How to use sockjs-client.CLOSED:

1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
  throw new Error('InvalidStateError: SockJS has already been closed');
}

this.readyState = SockJS.CLOSING;
setTimeout(function() {
  this.readyState = SockJS.CLOSED;

  if (forceFail) {
    this.dispatchEvent(new Event('error'));
  }

How to use sockjs-client.CLOSING:

1076
1077
1078
1079
1080
1081
1082
1083
1084
1085

if (this.readyState === SockJS.CLOSED) {
  throw new Error('InvalidStateError: SockJS has already been closed');
}

this.readyState = SockJS.CLOSING;
setTimeout(function() {
  this.readyState = SockJS.CLOSED;

  if (forceFail) {