Sharing connection between Browser's windows and tabs

nepa edited this page Oct 23, 2012 · 3 revisions

FAQ

Step by Step Tutorials

Concepts & Architecture

15 Minutes Tutorial

Advanced Topics

API

Known WebServer Issues

References

External Documentations

githalytics.com alpha

Clone this wiki locally

By default, the atmosphere.js library will open a new connection (based on the available transports: websocket, long-polling, streaming, sse, jsonp or ajax) every time a new window or tab is opened by the Browser. In some case it may be more efficient to share a connection between windows/tabs. To enable the mechanism, all you need to do is to set the shared property of an AtmosphereRequest object:

  var request = new $.atmopshere.AtmosphereRequest();
  request.shared = true;
  request.transport = 'websocket'
  $.atmosphere.subscribe(request);

Now every time a new windows/tabs is opened, the connection will be shared and all events occurring on that connection will be dispatched to all windows/tabs.