Perhaps, I'll try and explain what was trying to do again.
- I created an XData Server for desktop clients
- I added in an echo server for mobile clients to work off-line
I expected I could replicate the changes from the desktop clients down to the mobile clients. However this didn't work. When I looked at the ECHO_LOG.ORIGIN_NODE_ID it was null for changes made by the desktop clients.
The XData Server was very simple I just dropped the XData components on a data module. I made a little class for the echo server, just copied what you done in the demo project. I created a member field for the class on the data module.
Here is the class I created
unit uEchoServer;
interface
uses
Aurelius.Drivers.Interfaces,
Aurelius.Engine.DatabaseManager,
XData.Server.Module,
System.SysUtils,
Sparkle.HttpSys.Server,
Sparkle.HttpServer.Context,
Sparkle.HttpServer.Module,
Sparkle.Sys.Timer,
Echo.entities,
Echo.Listeners,
Echo.Server,
Echo.Main;
type
TMyEchoServer = class
private
FBaseUrl : string;
FEcho : TEcho;
FEchoModule : TEchoServerModule;
FEchoSubscriber: TEchoEventSubscriber;
FHttpSysServer : THttpSysServer;
FNodeManager : IEchoNodeManager;
FPool : IDBConnectionPool;
FTimer : TSparkleTimer;
public
constructor Create( ABaseUrl: string; APool: IDBConnectionPool );
destructor Destroy; override;
procedure Start;
procedure Stop;
end;
implementation
uses
System.IOUtils;
constructor TMyEchoServer.Create( ABaseUrl: string; APool: IDBConnectionPool );
begin
inherited Create;
FBaseUrl := ABaseUrl;
FPool := APool;
FHttpSysServer := nil;
FEcho := nil;
FTimer := nil;
TDatabaseManager.Update( APool.GetConnection, TEcho.Explorer );
end;
destructor TMyEchoServer.Destroy;
begin
Stop;
inherited;
end;
procedure TMyEchoServer.Start;
begin
if Assigned( FHttpSysServer ) then
Exit;
FHttpSysServer := THttpSysServer.Create;
FEchoModule := TEchoServerModule.Create( FBaseUrl, FPool );
FHttpSysServer.AddModule( FEchoModule );
FEcho := TEcho.Create( FPool );
FNodeManager := FEcho.GetNodeManager;
if FNodeManager.SelfNode = nil then
begin
FNodeManager.CreateNode( 'server' );
FNodeManager.DefineSelfNode( 'server' );
end;
FEchoSubscriber := TEchoEventSubscriber.Create;
FEchoSubscriber.SubscribeListeners;
FTimer := TSparkleTimer.Create(
procedure( FEcho: TObject )
begin
TEcho( FEcho ).BatchLoad;
TEcho( FEcho ).Route(
procedure( Log: TEchoLog; Node: TEchoNode; var Route: Boolean )
begin
// if SameText( Log.EntityClass, 'AppEntities.TEchoInvoice' )
// and ( Node.Id = 'Client1' ) then
// Route := false;
end
);
end,
FEcho, 2000, TTimerType.Periodic );
FHttpSysServer.Start;
end;
procedure TMyEchoServer.Stop;
begin
FEchoSubscriber.UnsubscribeListeners;
FEchoSubscriber.Free;
FreeAndNil( FHttpSysServer );
FreeAndNil( FEcho );
FreeAndNil( FTimer );
end;
end.
Here's what I got in the ECHO_LOG table. The null ORIGIN_NODE_ID's were created by the TMyEchoServer's FEchoEventSubscriber.
Is that any clearer?
Anyway, I gave up with the XData Server and just use the Echo Server which actually works better with what I need to do.