Knowledge Base

  1. Home
  2. Knowledge Base
  3. Technical Support
  4. Script Commands
  5. Synchronization commands

testRTC offers powerful synchronization capabilities. These can be used to synchronize across the probes that are running within a given test. These are:

rtcSetSessionValue()

Information sharing between probes that are part of the same session. This function, together with .rtcWaitForSessionValue(), can be used for information sharing and for probes’ synchronization.

Within a session of a test, one probe will call .rtcSetSessionValue() and other probes in the session should call .rtcWaitForSessionValue() with the same key parameter.

.rtcSetSessionValue() has no real use if you don’t set the #session run option for your test or if #session:1.

For further information about sessions management, please refer to Writing Scripts – Sessions.

Arguments:

Name Type Description
key string

The key to share across probes in the same session

value string The value to set for the key

Code example:

The code below makes all probes in the session to wait until the probe with index value 1 within the session group (the first probe) gets to a certain point in the script.

var idx = Number(process.env.RTC_IN_SESSION_ID);

if (idx === 1)
{
  client
    // Probe 1 sends a message
    .rtcSetSessionValue("readyToReceiveCalls", "Ready")
}
else
{
  client
    // Other probes receive the message
    .rtcWaitForSessionValue('readyToReceiveCalls', function (value) {}, 30000)
}

rtcWaitForSessionValue()

Information sharing between probes that are part of the same session. This function, together with .rtcSetSessionValue(), can be used for information sharing and for probes’ synchronization.

This function will wait until the requested parameter is received. The function receives a single parameter holding the value provided in the call to .rtcSetSessionValue() by another probe.

See .rtcSetSessionValue() above for a code example.

Arguments:

Name Type Description
key string The key to wait for
callback function The function that will be called when the value of the given key has been received
 time number The maximum number of milliseconds to wait. If this time passes, the test will fail

rtcSetTestValue()

Similar to .rtcSetSessionValue(), the .rtcSetTestValue() offers the ability to synchronize and share information across probes in a test. The difference is that .rtcSetTestValue() enables sharing that information across all probes, regardless of which session they belong to.

Catching the values passed by .rtcSetTestValue() is done by calling .rtcWaitForTestValue().

rtcWaitForTestValue()

This command waits for messages sent by a call to .rtcSetTestValue().

Was this article helpful?

Related Articles

Leave a Reply 0 comments

Leave a Reply: