Support & information center

rtcSetSessionValue()

testRTC allows you to share key/value pairs between the probes that are part of the same session. This script command together with .rtcWaitForSessionValue() can be used for such information sharing and for synchronization across probes.

Within a session of a test run, one probe will call .rtcSetSessionValue(). This will generate a key/value pair that will be stored in a shared memory across all probes in the same session. The other probes can then call .rtcWaitForSessionValue() with the same key parameter to retrieve the value.

Arguments

NameTypeDescription
keystringThe 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. If the value isn’t received within 30 seconds, the other probes in the session will fail the test.

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);
}Code language: JavaScript (javascript)

Notes

  • This method is useful for:
    1. Synchronizing probes to start after a given point in time, such as having the students join a session after the teacher logs in, or dial a call after the other user becomes available
    2. Send information that is needed, such as the URL or session ID that is created ad hoc by one probe that is needed for the other probes in order to join the same session
  • .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:

Was this article helpful?

Related Articles