#1 2013-12-03 22:05:14

nirnir
Member
Registered: 2013-11-11
Posts: 66

AV when drop session (return true) in OnSessionCreate

I modified sampel14 server to demonstrate

/// this server will use TSQLRestServerFullMemory over HTTP
program Project14ServerHttp;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Classes,
  SynCommons,
  mORMot,
  mORMotHttpServer,
  Project14Interface;

type
  TServiceCalculator = class(TInterfacedObject, ICalculator)
  public
    function Add(n1,n2: integer): integer;
  end;
  Tclass = class
   function sessionCreated(Sender: TSQLRestServer; Session: TAuthSession; Ctxt: TSQLRestServerURIContext):boolean;
  end;
  function TServiceCalculator.Add(n1, n2: integer): integer;
  begin
    result := n1+n2;
  end;

  function Tclass.sessionCreated(Sender: TSQLRestServer; Session: TAuthSession; Ctxt: TSQLRestServerURIContext):boolean;
  begin
    result := true;
  end;
var
  aModel: TSQLModel;
  aServer: TSQLRestServer;
  aHTTPServer: TSQLHttpServer;
  aclass  : Tclass;
begin
  // define the log level
  with TSQLLog.Family do begin
    Level := LOG_VERBOSE;
    EchoToConsole := LOG_VERBOSE; // log all events to the console
  end;
  aclass  := Tclass.create;
  // create a Data Model
  aModel := TSQLModel.Create([],ROOT_NAME);
  try
    // initialize a TObjectList-based database engine
    aServer := TSQLRestServerFullMemory.Create(aModel,'test.json',false,true);
    try
       aServer.OnSessionCreate:= aclass.sessionCreated;
      // register our ICalculator service on the server side
      aServer.ServiceRegister(TServiceCalculator,[TypeInfo(ICalculator)],sicShared);
      // launch the HTTP server
      aHTTPServer := TSQLHttpServer.Create(PORT_NAME,[aServer],'+',useHttpApiRegisteringURI);
      try
        aHTTPServer.AccessControlAllowOrigin := '*'; // for AJAX requests to work
        writeln(#10'Background server is running.'#10);
        writeln('Press [Enter] to close the server.'#10);
        readln;
      finally
        aHTTPServer.Free;
      end;
    finally
      aServer.Free;
    end;
  finally
    aModel.Free;
  end;
end.

Offline

#2 2013-12-04 13:47:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: AV when drop session (return true) in OnSessionCreate

Indeed.

Should be fixed by http://synopse.info/fossil/info/e50f14f798

Thanks for the feedback.

Offline

Board footer

Powered by FluxBB