Platform SDK: Agent |
Part | Description |
---|---|
Request | Returns the Request object. |
The event returns a Request object. Because requests are processed asynchronously, you can use this event to determine when the server begins processing a request (such as a Get, Play, or Speak method) and thereby synchronize this with other actions generated by your application. The event is sent only to the client that created the reference to the Request object and only if you defined a global variable for the request reference:
Dim MyRequest Dim Genie Sub window_Onload Agent1.Characters.Load "Genie", _ "http://agent.microsoft.com/characters/v2/genie/genie.acf" Set Genie = Agent1.Characters("Genie") ' This syntax will generate RequestStart and RequestComplete events. Set MyRequest = Genie.Get("state", "Showing") ' This syntax will not generate RequestStart and RequestComplete events. Genie.Get ("state", "Hiding") End Sub Sub Agent1_RequestStart(ByVal Request) If Request = MyRequest Then Status = "Loading the Showing animation" End Sub
The Status returns 4 (request in progress) for the Request object returned.
Because animation Request objects don't get assigned until the server processes the request, make sure that the Request object exists before you attempt to evaluate it. For example, in Visual Basic, if you use a conditional to test whether a specific request was completed, you can use the Nothing keyword:
Sub Agent1_RequestStart (ByVal Request) If Not (MyRequest Is Nothing) Then If Request = MyRequest Then '-- Do whatever End If End If End Sub
Note In VBScript 1.0, this event fires even if you don't define references to a Request object. This has been fixed in VBScript 2.0, which can be downloaded from http://microsoft.com/msdownload/vbscript/scripting.asp.