#1 Re: mORMot 1 » Implementing client functionality in dll » 2014-09-30 10:41:44

"I" is global variable. I got AV in ServerTimeStampSynchronize. Stack trace just before AV is:

SynCrtSock.TWinHTTP.InternalSendRequest('')
SynCrtSock.TWinHttpAPI.Request(???,???,20000,'','',???,'','')
mORMotHttpClient.TSQLHttpClientWinGeneric.InternalRequest('root/TimeStamp','GET','','','application/json; charset=UTF-8')
mORMotHttpClient.TSQLHttpClientGeneric.InternalURI($12FDA0)
mORMot.TSQLRestClientURI.URI('root/TimeStamp','GET',$12FE74 {''},$12FE34 {''},nil {''})
mORMot.TSQLRestClientURI.CallBackGet(???,???,'',nil,0,nil {''})
mORMot.TSQLRestClientURI.ServerTimeStampSynchronize
wm2_connect.connect

#2 mORMot 1 » Implementing client functionality in dll » 2014-09-30 08:39:45

VladimirPromAuto
Replies: 2

Hi
I need to implement client as dll. I use sample 14 - Interface based services.
I export procedure "connect":

var
  I: IConnection;
  Model: TSQLModel;
  Client: TSQLRestClientURI;
procedure connect;
begin
  I:= nil;
  Model := TSQLModel.Create([],ROOT_NAME);
  Client := TSQLHttpClient.Create('127.0.0.1','888',Model);
  if not Client.ServerTimeStampSynchronize then begin
    Client.Free;
    Model.Free;
  end
  else  begin
    Client.SetUser('User','synopse');
    Client.ServiceRegister([TypeInfo(IConnection)],sicPerSession);
    Client.Services['Connection'].Get(I);
    if (I <> nil) then   I.wm2_connect_start;
  end;
end;

Everything compiled without mistakes. But when this procedure called, I get exception "Access violation" on TWinHTTP.InternalSendRequest(const aData: RawByteString);
If I put this code in place of the reference to the exported dll function, everything works well.
What am I doing wrong?
Thanks.

Board footer

Powered by FluxBB