You are not logged in.
Hello ab,
working with callback interface I tried to return value from a function OR an out param from a procedure.
Both of tries result error failed: unexpected parameter "result"
ISpotCallBack= interface(IInvokable)
['{F8D9E6D3-F435-4C06-923A-9B7D12BBE2E6}']
procedure IsOk(a: Integer; out b: Boolean);
OR
Function IsOk(a: Integer): Boolean;
end;
From server's error log
20170803 07263359 ' EXC EInterfaceFactoryException {"Message":"TInterfacedObjectFakeServer.FakeCall(ISpotCallBack.IsOk) failed: unexpected parameter \"result\""} at 004FC9BF mORMot.RaiseError (32126) stack trace API 004FC9BF mORMot.RaiseError (32126) 004FCDCF mORMot.InternalProcess (32126) 004FD53D mORMot.TInterfacedObjectFake.FakeCall (32126)
Digging on mORMot client code
procedure TSQLRestClientURI.InternalNotificationMethodExecute
...
WR.AddShort('{"result":[');
if frames='[0]' then // call before the first method of the jumbo frame
Call(callback.Factory.MethodIndexCurrentFrameCallback,frames,nil);
Call(methodIndex,Ctxt.InBody,WR);
if ok then begin
if Ctxt.OutHead='' then begin // <>'' if set via TServiceCustomAnswer
WR.Add(']','}');
...
found that build a json {"result":[true]} that is not acceptable on server side code
function TInterfacedObjectFake.FakeCall(var aCall: TFakeCallStack): Int64;
...
smvBoolean..smvWideString: begin
Val := GetJSONField(R,R,@wasString,nil,@ValLen);
...
GetJSONField retrun nil
Can you help?
Offline
I do not know how to change routing but debugging the app and see that both client/server use
TSQLRestRoutingREST.
Is something that I miss?
Offline
I change Project31 / LongWorkServer / LongWorkClient and add a callback function with result integer and I get the same error
"missing or invalid value" .
Correction "unexpected parameter" get when call a procedure with out/var parameter
Is callback interfaces supporting functions or var/out parameters?
Offline
I guess there is something wrong somewhere.
My idea was that it was tested in TTestBidirectionalRemoteConnection.TestCallback method, but in fact, it appears that it was not the case!
I will check again, and turn back here.
Offline
I run "TestSQL3" tests and I add a breakpoint on procedure TSQLRestClientURI.InternalNotificationMethodExecute
line 36685
WR.AddShort('{"result":[');
When execution passed there are three methods
ServiceRecordVersionCallback.Deleted
ServiceRecordVersionCallback.Updated
BidirCallback.AsynchEvent
all three methods do not have return or var/out parameters.
I think there is a problem or not supported callback with functions Or var/out parameters.
Please take a look because I try all day and I can't find a solution.
Take as a reference LongWorkServer/client demo and add a callback with functions Or var/out parameters.
Offline
Please check https://synopse.info/fossil/info/2eb7a6543e
Should be fixed now.
I've also enhanced the regression tests to cover this feature.
Offline
Thank you Arnaud.
I will try it today
Offline