new ConnectionSharing(shareName, sharePolicyOnFound, sharePolicyOnNotFound, preventCrossWindowShare, shareRef)
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 informations across windows. The used keys
are prefixed with the "Lightstreamer_" string. Specifiyng 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.
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 | 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. |
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).
Can be one of the following:
|
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).
Can be one of the following:
|
preventCrossWindowShare |
boolean | [optional] Flag to enable/disable the sharing
of a connection that belongs to a LightstreamerClient instances living
in a different html page.
Note that cross-window sharing might be impossible in certain circumstances. If this flag is set to true, a Master living on a different window will not trigger the sharePolicyOnFound policy; hence, only sharing with another LightstreamerClient instance belonging to the same page will be possible. The parameter is optional; if not supplied, the default value is false. |
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.
-
Method Summary
- getShareName
- Inquiry method that returns the share name configured in this instance.
Method Detail
-
getShareName() → {String}
-
Inquiry method that returns the share name configured in this instance.
Returns:
The configured share name.- Type
- String