UserSignal Function

Action

Is used to notify a virtual user, which is in a waiting state as a result of having called the UserWaitFor function. UserSignal is typically called from within a callback function in order to notify a virtual user about a particular event. The function takes a name as parameter to identify an event object to be signaled.

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

UserSignal( in sWaitObjectName : string ): boolean;
Parameter Description
sWaitObjectName Name to identify the event object to be signaled.

Return value

  • True if the event object was signaled.
  • False otherwise. 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;