Skip to content
Pablo Ojanguren edited this page Mar 20, 2017 · 1 revision

Advanced Topics

Cookies and CORS

When the SwellRT JavaScript API client and your App are not in the same domain/subdomain you could run into issues with some browser forcing the Same Origin Policy.

WebSockets and Long-Polling

By default, SwellRT's JavaScript client will communicate with the server using the WebSocket protocol if it is available. If not, the fallback protocol will be long-polling. If you want to force disabling WebSockets, call the following method just before start a new session:

SwellRT.useWebSocket(false);

Detecting obsolete JavaScript clients

In some situations cached versions of the JavaScript client library became obsolete. In order to avoid further issues and allowing apps to reload the JS client properly, a global FATAL_EXCEPTION will be raised with the value data.cause = CLIENT_UPGRADE if the SwellRT server can't work with current client's version.

Tunning transport protocol

For tunning the underlying Atmosphere JavaScript client, applications can define the following object before doing operation with the SwellRT API:

window.__atmosphere_config = {

  logLevel: "info", // info, debug
  transport: "websocket",
  fallbackTransport: "long-polling",
  pollingInterval: 5000,
  trackMessageLength: true,
  enableXDR: true,
  readResponsesHeaders: false,
  withCredentials: true,
  dropHeaders: true,
  timeout: 27000,

  connectTimeout: -1,
  reconnectInterval: 5000,
  maxReconnectOnClose: 5,
  reconnectOnServerError: true,

};