UserWaitFor Function

Action

Pauses the execution of a virtual user until notified to continue. The notification is typically sent from within a callback function. UserWaitFor takes a name as parameter to identify an event object that can be signaled by the UserSignal function.

The scope of this function is the virtual user context, which means that virtual users that use the same event object, do not interfere with each other.

Include file

kernel.bdh

Syntax

UserWaitFor( in sWaitObjectName : string
             in nTimeout        : number optional ): boolean;
Parameter Description
sWaitObjectName Name to identify the event object, which a virtual user is waiting to be signaled for
nTimeout Optional: Timeout for setting the value in seconds. If the specified time period is exceeded, the virtual user indicates an error and continues execution. The function's default behaviour is to wait forever.

Return value

  • True if the event object was signaled within the specified timeout.
  • False otherwise. If an error other than a timeout occurred, the virtual user logs an error message.

Example

dclfunc
  function FAsyncCallback(sResponseBody : string) <ASYNC_CALLBACK_FUNCTION>
  begin
    RepMessage("MESSAGE: '" + sResponseBody + "'", SEVERITY_INFORMATIONAL);
    if (StrSearch(sResponseBody, "last message", STR_SEARCH_FIRST) <> 0) then
      UserSignal("LastMessage");
    end;
  end FAsyncCallback;

dcltrans
  transaction TMainListen
  var
    nAsyncChannel : number;
  begin
    WebPageUrl("http://lnz-testsite:8080/atmosphere-meteor-pubsub-2.0.3/", "/atmosphere-meteor-pubsub-2.0.3/");
    nAsyncChannel := WebAsyncPreparePush(callback(FAsyncCallback));
    WebFormGet("http://lnz-testsite:8080/atmosphere-meteor-pubsub-2.0.3/pubsub/mychannel_1234", 
      METEOR_PUB_SUB_FORM);

    UserWaitFor("LastMessage", 60); 
    
    WebAsyncStop(nAsyncChannel);
    
  end TMainListen;