#1 2013-07-03 13:15:02

corchi72
Member
Registered: 2010-12-10
Posts: 232

Server push to client?

Sorry but I did not understand if you have already implemented the function of pushing the server to the client?

http://blog.synopse.info/post/2012/09/0 … laboration

thanks Corchi72

Offline

#2 2013-07-03 13:23:35

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

Re: Server push to client?

Not yet.

Offline

#3 2013-07-03 13:48:14

corchi72
Member
Registered: 2010-12-10
Posts: 232

Re: Server push to client?

ok Thanks

Then I can insert into (specific) client another server (type THttpApiServer)  without authentication, and without tables, that receives impulses from the real server?

  fServer := THttpApiServer.Create(false);
  fServer.AddUrl('root','888',false,'+',true);
  fServer.RegisterCompress(CompressDeflate); // our server will deflate html :)
  fServer.OnRequest := Process;
  fPath := IncludeTrailingPathDelimiter(Path);

and then work with the interfaces?

Last edited by corchi72 (2013-07-03 13:49:06)

Offline

#4 2013-07-03 15:20:41

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

Re: Server push to client?

You can do this, but you will need to do all the firewall settings to access your client from the server side.
smile

Just uses a TSQLRestServerFullMemory instance on the client side, so you won't need any link to SQLite3 in the executable, but still have the whole routing and authentication if needed.
See the samples using this kind of class.
A blank THttpApiServer won't be enough to serve interface based services (or method-base services), just to send some content over HTTP.

Offline

#5 2013-07-03 17:02:22

corchi72
Member
Registered: 2010-12-10
Posts: 232

Re: Server push to client?

don't work , I must to create  table with "CreateMissingTables"  ([TSQLAuthUser,TSQLAuthUser])

var
  aModel: TSQLModel;
  aDB: TSQLRestServer;
  aServer: TSQLHttpServer;
begin
  // initialize the ORM data model
  aModel := TSQLModel.Create([TSQLAuthUser,TSQLAuthUser],ROOT_NAME);

  try
    // create a fast in-memory ORM server
    aDB := TSQLRestServerFullMemory.Create(aModel,'xxx.json',false,true);
    aDB.CreateMissingTables(ExeVersion.Version.Version32);
      // launch the HTTP server
    aServer := TSQLHttpServer.Create(inttostr(888+1),[aDB],'+',useHttpApiRegisteringURI);

    aServer.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries

    aDB.ServiceRegister(TRemoteAction,[TypeInfo(IRemoteAction)],sicShared);


  finally
    aModel.Free;
  end;

sorry but what should I write to connect from the client and use the interface

I wrote the following code but an error occurs I can not run the setuser:

var
  Client:TSQLHttpClient;
  aModel: TSQLModel;
  sServer: AnsiString;
  I:IRemoteAction;
begin
 sServer := 'localhost';
  try
    aModel := TSQLModel.Create([],ROOT_NAME);
    try
    Client := TSQLHttpClient.Create(sServer,inttostr(888+1) ,aModel);
    if Client.SetUser('Admin','Synopse') then
       Client.ServiceRegister([TypeInfo(IRemoteAction)],sicShared);


    if not Client.Services['RemoteAction'].Get(I) then
    exit;
    I.Update(ID);


    finally
    Client.Free;
    end;
  finally
    aModel.Free;
  end;
end;

Offline

#6 2013-07-03 17:43:37

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

Re: Server push to client?

Yes, this is as expected: both tables are needed.
But you can stay all data in memory, so it is not a problem.

Offline

#7 2013-07-05 09:33:21

corchi72
Member
Registered: 2010-12-10
Posts: 232

Re: Server push to client?

the server side, I recorded the following interface. the interface performs a process that takes 1 minute and everything works, but after a few seconds an error occurs 12001 of face + interface name call ..

Why?


procedure TDMDServer.CreateServerInMemory;
begin

 with TSQLLog.Family do begin
    Level := [sllError,sllInfo,sllDebug];  //LOG_VERBOSE
    EchoToConsole := [sllError,sllInfo,sllDebug];
    AutoFlushTimeOut := 2;
    DestinationPath := GetTempDir;
    OnArchive := EventArchiveSynLZ;
    //OnArchive := EventArchiveZip;
    ArchiveAfterDays := 1; // archive after one day
  end;
  // initialize the ORM data model
  MemoryModel := TSQLModel.Create([],ROOT_NAME);
  try
    // create a fast in-memory ORM server
     MemoryDB := TSQLRestServerFullMemory.Create(MemoryModel,'Memory',false,false);
      // register our TRemoteAction implementation
     MemoryDB.ServiceRegister(TRemoteAction,[TypeInfo(IRemoteAction)],sicShared);
      // launch the HTTP server
     MemoryServer := TSQLHttpServer.Create(inttostr(fNuvRegistry.ScheduleServerHttpPort),[MemoryDB],'+',useHttpApiRegisteringURI);
    

     MemoryServer.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
  

  except
    
  end;

end;

Offline

#8 2013-07-05 10:58:52

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

Re: Server push to client?

One minute?

Offline

#9 2013-07-05 12:09:19

corchi72
Member
Registered: 2010-12-10
Posts: 232

Re: Server push to client?

No I was wrong to writing the process takes about 1 minute, but the error occurs after a few seconds

Offline

#10 2014-03-21 09:27:51

ncesi
Member
Registered: 2013-03-01
Posts: 3

Re: Server push to client?

What is the status about pushing from server to the client functionality? :-)

Offline

#11 2014-03-21 09:34:38

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Re: Server push to client?

This can hep too me.

Offline

#12 2014-03-21 12:46:35

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

Re: Server push to client?

Feature is listed, but not yet implemented.
This is not on our high-priority list!
(remember we are not paid for the framework, so we maintain our own priority list for features, unless we are asked and paid for a specific feature - see http://blog.synopse.info/post/2014/02/2 … -free-beer )
smile

But this may be a very useful feature.
In the meanwhile, you can define a timer to periodically ask the server for updates.
This is what we do in our current implementations, and is still stateless.

Offline

Board footer

Powered by FluxBB