Knowledge Base

  1. Home
  2. Knowledge Base
  3. General
  4. How-to
  5. 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 === 0) 
{
    // The callee
    client
        .rtcInfo("The callee")        
         
         // Preparations
         
         // Signal the caller that we are ready to receive the call
        .rtcSetSessionValue("sessionReady", "Ready")
        
        // Wait for the call

        // Answer
        .click('#answer');
}
else
{
    // The caller
    client
        .rtcInfo("The caller")
        
        .rtcProgress("Calling")

        // 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
        .click('#call');
}

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

 

Was this article helpful?

Related Articles

Leave a Reply 0 comments

Leave a Reply: