Everytime, hbTapi calls an asynchronous TAPI function, an internal request
object will be created. This object holds information like the request
ID, the request type, a timeout value and the participating objects (e.g.
calls). You are able to store your own information within the request
object by using the ThbTapiLine.SetRequestNote
method. The function GetRequestNote is used to query these information
of a request. Especially if you are using the asynchronus mode of hbTapi,
this function is very helpfull. It provides you with a simple possibility
to get information of a request identified by its request ID.
Declaration
function GetRequestNote(RequestID: Integer;
Ident: String): Variant;
Parameters
RequestID
ID of an existing request. Use ThbTapiLine.LastRequestID
or a request id given by the parameter RequestID within a ThbTapiLine
event. If no request with the given id exists, an exception will be
raised.
Ident
Identifier of the needed information. There are two kinds of identifiers:
internal and user defined. Use the method ThbTapiLine.SetRequestNode
to store an information using an user defined identifier. All Internal
identifiers are beginning with a '&' like '&TapiRequest'.
Returns the information specified by Ident as a Variant.
Use a typecast to convert it into the needed type.
Remarks
The most often used information is the type of the request.
The following example gets the type of a failed request to display a corresponding
message dialog.
interface
uses hbTapi, tapi, ...
procedure TForm1.hbTapiLine1TapiReply(Sender: TObject; RequestID, ReplyCode:
Cardinal);
var tr: DWORD;
begin
if (ReplyCode <> 0) then
begin
tr := hbTapiLine1.GetRequestNote(RequestID, '&TapiRequest');
case tr of
TAPIREQUEST_LINEMAKECALL :
MessageDlg('TapiReply:
MakeCall failed!' +#13 + #10 + GetTapiErrorMessage(ReplyCode), mtError,
[mbOK], 0);
TAPIREQUEST_LINEDROP :
MessageDlg('TapiReply:
DropCall failed!' +#13 + #10 + GetTapiErrorMessage(ReplyCode), mtError,
[mbOK], 0);
TAPIREQUEST_LINEANSWER :
MessageDlg('TapiReply:
AnswerCall failed!' +#13 + #10 + GetTapiErrorMessage(ReplyCode), mtError,
[mbOK], 0);
else
MessageDlg('TapiReply: Error' +#13
+ #10 + GetTapiErrorMessage(ReplyCode), mtError, [mbOK], 0);
end
end;
end;
The following example shows how to store an information
together with the request and how to retrieve it back in ThbTapiLine.OnTapiReply.
The number of created calls are store in the variable FNumMakeCall and
ist given to request. ThbTapiLine.OnTapiReply this information is retrieved
and used to display a message dialog.
interface
uses hbTapi, tapi, ...
procedure TForm1.DoMakeCall(Sender: TObject);
begin
try
hbTapiLine1.MakeCall(EditPhoneNo.Text);
inc(FNumMakeCall);
hbTapiLine1.SetRequestNote(hbTapiLine1.LastRequestID,
'NumMakeCall', FNumMakeCall);
except
on E:EhbTapiError do
MessageDlg('MakeCall failed! ' + E.Message,
mtError, [mbok], 0);
end;
end;
procedure TForm1.hbTapiLine1TapiReply(Sender:
TObject; RequestID, ReplyCode: Cardinal);
begin
if (ReplyCode <> 0) then
begin
if hbTapiLine1.GetRequestNote(RequestID, '&TapiRequest')
= TAPIREQUEST_LINEMAKECALL then
MessageDlg(Format('TapiReply: MakeCall
#%d failed! %s', [Integer(hbTapiLine1.GetRequestNote(RequestID, 'NumMakeCall')),
GetTapiErrorMessage(ReplyCode)]),
mtError, [mbOK], 0);
else
MessageDlg('TapiReply: Error' +#13
+ #10 + GetTapiErrorMessage(ReplyCode), mtError, [mbOK], 0);
end
end;