setReverseHeartbeatInterval method
Setter method that enables/disables the reverse-heartbeat mechanism by setting the heartbeat interval.
If the given value (expressed in milliseconds) equals 0 then the reverse-heartbeat mechanism will be disabled; otherwise if the given value is greater than 0 the mechanism will be enabled with the specified interval.
When the mechanism is active, the client will ensure that there
is at most the specified interval between a control request and the following one,
by sending empty control requests (the "reverse heartbeats") if necessary.
This can serve various purposes:
- Preventing the communication infrastructure from closing an inactive socket
that is ready for reuse for more HTTP control requests,
to avoid connection reestablishment overhead. However it is not guaranteed that the connection will be kept open,
as the underlying TCP implementation may open a new socket each time a HTTP request needs to be sent.
Note that this will be done only when a session is in place. - Allowing the Server to detect when a streaming connection or Websocket is interrupted but not closed. In these cases, the client eventually closes the connection, but the Server cannot see that (the connection remains "half-open") and just keeps trying to write. This is done by notifying the timeout to the Server upon each streaming request. For long polling, the [setIdleTimeout] setting has a similar function.
- Allowing the Server to detect cases in which the client has closed a connection in HTTP streaming, but the socket is kept open by some intermediate node, which keeps consuming the response. This is also done by notifying the timeout to the Server upon each streaming request, whereas, for long polling, the [setIdleTimeout] setting has a similar function.
Default 0 (meaning that the mechanism is disabled).
Lifecycle This setting should be performed before calling the LightstreamerClient.connect method. However, the value can be changed at any time: the setting will be obeyed immediately, unless a higher heartbeat frequency was notified to the Server for the current connection. The setting will always be obeyed upon the next connection (either a bind or a brand new session).
Notification A change to this setting will be notified through a call to ClientListener.onPropertyChange with argument "reverseHeartbeatInterval" on any ClientListener listening to the related LightstreamerClient.
newVal
the interval, expressed in milliseconds, between subsequent reverse-heartbeats, or 0.
Throws IllegalArgumentException if a negative value is configured
Implementation
Future<void> setReverseHeartbeatInterval(int newVal) async {
_reverseHeartbeatInterval = newVal;
var arguments = <String, dynamic> {
'newVal': newVal
};
return await _invokeMethod('setReverseHeartbeatInterval', arguments);
}