Constructor
new ConnectionSharing(shareName, sharePolicyOnFound, sharePolicyOnNotFound, preventCrossWindowShareopt, shareRefopt)
Data object describing the sharing policies to be used by a LightstreamerClient
instance.
If the front-end includes more than one LightstreamerClient instance that
need to subscribe to the same server, it is advised that such instances
share the same connection to avoid saturating the client connection pool and
to open fewer sessions on the Lightstreamer Server.
Note that sharing is also possible between clients living in different
HTML pages, provided that they come from the same host. Note that Browser
capabilities and/or restrictions might prevent the sharing.
If sharing is enabled some Cookies or values on the Web Storage may
be used to exchange preliminary information across windows. The used keys
are prefixed with the "Lightstreamer_" string. Specifying true on the
preventCrossWindowShare parameter it is possible to prevent the
Cookies/Web Storage usage.
When different LightstreamerClient share the same connection, the one
actually holding the connection is also known as the current "Master" client.
Whenever possible, the Master LightstreamerClient should be hosted by a permanent page.
If the current Master, for any reason, disappears, then the connection to
Lightstreamer Server has to be reestablished: the election algorithm will
choose a new Master among the surviving LightstreamerClient instances and
will restore the same status that was in place before the previous Master
disappeared.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
shareName |
String |
A unique alphanumeric name for the shared connection. The name can be used by different LightstreamerClient in order to recognize a compatible shared connection. Two LightstreamerClient instances should use the same shareName for their enableSharing calls only if they are going to configure the connection in the same way to connect to the same server. Obviously, this includes the user credentials. |
|
sharePolicyOnFound |
String |
The action to be taken in case a client
sharing a connection using the same shareName and coming from the same
host is found in the browser (i.e. an active Master is found).
|
|
sharePolicyOnNotFound |
String |
The action to be taken in case a client
sharing a connection using the same shareName and coming from the same
host is not found in the browser (i.e. no active Master is found).
|
|
preventCrossWindowShare |
boolean |
<optional> |
[optional] Flag to enable/disable the sharing
of a connection that belongs to a LightstreamerClient instances living
in a different html page.
|
shareRef |
Window |
<optional> |
If known, the reference to a Window containing a shared connection can be passed. For the passed reference to be used, "ATTACH" or "ATTACH:FAST" should be used as sharePolicyOnFound. |
Throws:
-
-
if the sharename is not specified or is invalid.
-
-
-
if a non-existent policy was specified or if the specified policy is not compatible with the current environment.
-
Methods
getShareName() → {String}
Inquiry method that returns the share name configured in this instance.
Returns:
The configured share name.
- Type
- String
isPossible()
Connection sharing is possible only if the environment supports SharedWorkers or the user requested a local sharing.