Skip to main content

Wait for an agent to register

Sometimes, you want the agents in your test case to log in to the system and register before other agents try and call them or interact with them. To that end, you can use .rtcSetSessionValue() and .rtcWaitForSessionValue() commands defined in testRTC.

The code sample below gets the first agent in each session to send out a message that it is ready to all other agents in the same session so they can start interacting with it.
var agentType = Number(process.env.RTC_IN_SESSION_ID); 

if (agentType === 1) 
    // The callee
        .rtcInfo("The callee")        
         // Preparations
         // Signal the caller that we are ready to receive the call
        .rtcSetSessionValue("sessionReady", "Ready")
        // Wait for the call

        // Answer
    // The caller
        .rtcInfo("The caller")

        // Wait until the callee is ready to receive the call
        .rtcWaitForSessionValue('sessionReady', function (ignoreMe) {}, 20000)

        .rtcInfo("The callee is ready. Initiating a Call...")

        // Initiate the call

// Shared code for both users after the call was started
    .rtcProgress("In a call")

Was this article helpful?

0 out of 0 found this helpful