Knowledge Base

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

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 the Session size you configure for the test is set to 1. You will find the Session Size of your script in the script editor itself:

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

Arguments:

NameTypeDescription
keystring

The key to share across probes in the same session

valuestringThe 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:

NameTypeDescription
keystringThe key to wait for
callbackfunctionThe function that will be called when the value of the given key has been received
 timenumberThe 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: