* Publish handler resulttype, add OnContextExecute

This commit is contained in:
Michaël Van Canneyt 2021-12-19 22:15:29 +01:00
parent 9af13b2731
commit 03b3f00a0b

View File

@ -118,21 +118,25 @@ Type
TCustomJSONRPCHandlerClass = Class of TCustomJSONRPCHandler;
TJSONRPCEvent = Procedure (Sender : TObject; Const Params : TJSONData; Out Res : TJSONData) of object;
TJSONContextRPCEvent = Procedure (Sender : TObject; aContext : TJSONRPCCallContext; Const Params : TJSONData; Out Res : TJSONData) of object;
{ TJSONRPCHandler }
TJSONRPCHandler = Class(TCustomJSONRPCHandler)
private
FOnExecute: TJSONRPCEvent;
FOnContextExecute : TJSONContextRPCEvent;
protected
Function DoExecute(Const Params : TJSONData; AContext : TJSONRPCCallContext): TJSONData; override;
Published
Property OnExecute : TJSONRPCEvent Read FOnExecute Write FOnExecute;
Property OnContextExecute : TJSONContextRPCEvent Read FOnContextExecute Write FOnContextExecute;
Property BeforeExecute;
Property AfterExecute;
Property OnParamError;
Property Options;
Property ParamDefs;
Property ResultType;
end;
{ TJSONRPCEcho }
@ -862,7 +866,9 @@ end;
function TJSONRPCHandler.DoExecute(const Params: TJSONData;AContext : TJSONRPCCallContext): TJSONData;
begin
Result:=Nil;
If Assigned(FOnExecute) then
If Assigned(FOnContextExecute) then
FOnContextExecute(Self,aContext,Params,Result)
else If Assigned(FOnExecute) then
FOnExecute(Self,Params,Result);
end;